See attachment for images
Why does the plotted line goe to the last bar when output1=high(-1) but ends before the last bar when output1=low(-1) ?
-----------------------------------------------
setStudyTitle("forum question");
var output1_dm2=null;
var output1_dm1=null;
var output1=null;
function preMain()
{setPriceStudy(true);}
function main()
{
output1_dm2=output1_dm1;
output1_dm1=output1;
output1=high(-1); // this output1 value plots study line all the way to last bar
//output1=low(-1); // this output1 value quits plotting 5 bars before last bar ????
if(output1-output1_dm1>=0)
{
Strategy.doLong("long", Strategy.LIMIT, Strategy.THISBAR, Strategy.DEFAULT, output1);
Strategy.doSell("long", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT,0);
}
else
{
Strategy.doShort("short", Strategy.LIMIT, Strategy.THISBAR, Strategy.DEFAULT, output1);
Strategy.doCover("short", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
}
return output1;
}
Why does the plotted line goe to the last bar when output1=high(-1) but ends before the last bar when output1=low(-1) ?
-----------------------------------------------
setStudyTitle("forum question");
var output1_dm2=null;
var output1_dm1=null;
var output1=null;
function preMain()
{setPriceStudy(true);}
function main()
{
output1_dm2=output1_dm1;
output1_dm1=output1;
output1=high(-1); // this output1 value plots study line all the way to last bar
//output1=low(-1); // this output1 value quits plotting 5 bars before last bar ????
if(output1-output1_dm1>=0)
{
Strategy.doLong("long", Strategy.LIMIT, Strategy.THISBAR, Strategy.DEFAULT, output1);
Strategy.doSell("long", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT,0);
}
else
{
Strategy.doShort("short", Strategy.LIMIT, Strategy.THISBAR, Strategy.DEFAULT, output1);
Strategy.doCover("short", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
}
return output1;
}
Comment