I know this is a stupid question but here goes. I want to draw a shape on a chart when a condition happens. High(0) > SwingHigh.
However I only want the shape to print once or twice. So I have added a counter, c, to control it.
if (High(0) > SwingHigh && counter < 7) draw
I then reset the counter when the initial condition is not true
if (High(0) < SwingHigh)
counter = 0;
but for some reason I cant get it to draw anything when I put my counter in. I think it has to do with declaring var c in the main section.
here is the full code. Thanks
However I only want the shape to print once or twice. So I have added a counter, c, to control it.
if (High(0) > SwingHigh && counter < 7) draw
I then reset the counter when the initial condition is not true
if (High(0) < SwingHigh)
counter = 0;
but for some reason I cant get it to draw anything when I put my counter in. I think it has to do with declaring var c in the main section.
here is the full code. Thanks
PHP Code:
function preMain() {
setPriceStudy(true);
setStudyTitle("BreakSwings");
setShowTitleParameters(false)
setComputeOnClose()
setShowSeries(true, 0);
setShowSeries(true, 1);
var c=0;
}
function main()
{ //m opening bracket
var c;
var vSwings5 = efsExternal("Swings.efs", 2, inv(5) );
var vSwingHigh5 = getSeries(vSwings5,0);
var vSwingLow5 = getSeries(vSwings5,1);
var vSwings30 = efsExternal("Swings.efs", 2, inv(30) );
var vSwingHigh30 = getSeries(vSwings30,0);
var vSwingLow30 = getSeries(vSwings30,1);
var lastswinghigh;
if( (high(0) > vSwingHigh5) )
if (c < 3)
{
drawShape(Shape.UPARROW, AboveBar1, Color.RGB(0,0,255));
c = c + 1;
}
if (high(0) < vSwingHigh5)
c = 0; // reset counter
return new Array (vSwingHigh5, vSwingLow5);
}
Comment