If I call drawLineAbsolute or drawLineRelative from main(), it seems to only draw the lines once - from the last time main() is executed.
So, in this example, it does color all the price bars green & red, and it also draws a line thru all the closes, so it does know which bar it's on each time main is called. But it only draws the high & low lines once, at the right end of the plot.
How do I get it to draw for each bar?
So, in this example, it does color all the price bars green & red, and it also draws a line thru all the closes, so it does know which bar it's on each time main is called. But it only draws the high & low lines once, at the right end of the plot.
/************************************************** *****************************
Tests drawLineRelative.
Date Major Changes
12mar2009 Created.
12mar2009
************************************************** *****************************/
g = {};
g.nBar = 0;
function preMain()
{
setStudyTitle ("Test of drawLineRelative");
setCursorLabelName ("Test1");
setPriceStudy (true);
}
function main(p_nPeriods, p_nBuy, p_nSell)
{
g.nBar += 1;
drawLineAbsolute (-1, high(-1), 0, high(), PS_SOLID, 1, Color.blue, "highs");
drawLineRelative (-1, low(-1), 0, low(), PS_SOLID, 1, Color.red, "lows");
if (g.nBar % 2)
{setPriceBarColor (Color.green, Color.green);
}
else
{setPriceBarColor (Color.red, Color.red);
}
return close(0);
}
Tests drawLineRelative.
Date Major Changes
12mar2009 Created.
12mar2009
************************************************** *****************************/
g = {};
g.nBar = 0;
function preMain()
{
setStudyTitle ("Test of drawLineRelative");
setCursorLabelName ("Test1");
setPriceStudy (true);
}
function main(p_nPeriods, p_nBuy, p_nSell)
{
g.nBar += 1;
drawLineAbsolute (-1, high(-1), 0, high(), PS_SOLID, 1, Color.blue, "highs");
drawLineRelative (-1, low(-1), 0, low(), PS_SOLID, 1, Color.red, "lows");
if (g.nBar % 2)
{setPriceBarColor (Color.green, Color.green);
}
else
{setPriceBarColor (Color.red, Color.red);
}
return close(0);
}
Comment