OnCalculate event doubt

 

Hi,


I am developing an indicator and I don't understand the OnCalculate event at all.

From what I can see, this indicator runs every time there is a new tick on the chart. So, I calculate for all candles the indicator (I limit it to 1000 candles)


for (int i = (int) MathMax (prev_calculated-1, rates_total-1000); i <rates_total; i ++)


Those candles are finished and therefore the indicator is calculated with every candle closed on the history.

But when the indicator has been calculated for history candles , I want it to only be calculated every time a candle is complete, not every time there is a tick.


How can I do it?


Thank you very much

 
Then you would only calculate for the former period if time[i-1] has changed.