I met a question of accessing last bar data in developing an indicator. It seemed that in the OnBarUpdate() for Indicators, the method cannot access last bar data. Is that true?
The code I wrote is :
ror.Set(Close[0]/Close[1]-1); //ror is a DataSeries object
double sd=StdDev(ror, 10)[0];
Plot0.Set(sd);
But it works if I wrote this way:
ror.Set(Close[0]/lastclose-1);
double sd=StdDev(ror, 10)[0];
Plot0.Set(sd);
lastclose=Close[0];
Can you explain it why is that?
Thanks,
Michael
Comment