Hi again, I added a Period limit and as mentioned, it stops Zorro from crashing. However, the code is not executed properly. It seems like for small difference (like 1 pip), 1 period is returned. However, increasing to 5 pips gives 1 period for most points, and spiking to the maximum allowed (1440) at points. The following code was run for EUR/USD:
var fxn_HL(var* Data, int Period)
{
int i=1; var HL=0.0;
while(HL<0.0005 and i<Period)
{
HL=HH(Data[i])-LL(Data[i]);
i=i+1;
}
return (i-1);
}
function run()
{
StartDate = 2013; // start the simulation with September 2005
LookBack=1440;
BarPeriod=60;
set(PLOTPRICE+PLOTNOW);
PlotBars = 20000;
var* Price = series(price());
vars HL_ser = series(fxn_HL(Price,1440));
vars HH_ser=series(HH(24));
vars LL_ser=series(LL(24));
plot("HL",HL_ser[0],NEW,BLUE);
plot("HH",HH_ser[0],NEW,BLUE);
plot("LL",LL_ser[0],NEW,BLUE);
}
The graph of HH and LL for the last 24 hours is plotted. As you can imagine, a 5 pip range must be obtained in every given past hour.
Am I making some huge mistake??