int lookback = ... // iMA(period) has look back of period. // buffer[i+2] has look back of 2 (as TimeSeries) // buffer[i-2] has look back of 2 (not TimeSeries) // use maximum of all.
New way, counting down as a TimeSeries (Bars always equals rates_total so can be substituted.)
Returning rates_total-1 makes prev_calculated the same as IndicatorCounted().
Alternatively if you return rates_total then must decrement prev_calculated if non-zero at the beginning of On_Calculate to recalculate the current bar.
Always count down so you're not using future values.
// buffer[i+2] has look back of 2 (as TimeSeries)
// buffer[i-2] has look back of 2 (not TimeSeries)
// use maximum of all.
Returning rates_total-1 makes prev_calculated the same as IndicatorCounted().
Alternatively if you return rates_total then must decrement prev_calculated if non-zero at the beginning of On_Calculate to recalculate the current bar.
Always count down so you're not using future values.
Thank you.. i have no idea how reading 2k bars is much more faster now!! really appreciate bro! :D