Download MetaTrader 5

why prev_calculated - 1?

To add comments, please log in or register
boscomanilow128
19
boscomanilow128  

hello guys,

   I have been thinking over days already, it seems that for all indicators, any counter with i = prev_calculated could do more than fine as it points towards the previous candle which is already a calculated figure. why bother to do i = prev_calculated - 1 at all?

  actually it seems to me that if prev_calculated really mean previously calculated, then we should even set i = prev_calculated + 1 for our calculation in OnCalculate()... Why not?

Bosco 

Alain Verleyen
Moderator
32022
Alain Verleyen  
boscomanilow128:

hello guys,

   I have been thinking over days already, it seems that for all indicators, any counter with i = prev_calculated could do more than fine as it points towards the previous candle which is already a calculated figure. why bother to do i = prev_calculated - 1 at all?

  actually it seems to me that if prev_calculated really mean previously calculated, then we should even set i = prev_calculated + 1 for our calculation in OnCalculate()... Why not?

Bosco 

Can you post at least one example of code.
enbo lu
Moderator
1937
enbo lu  

this article mightbe helpful: Creation of Custom Indicators

Creation of Custom Indicators - Simple Programs in MQL4 - MQL4 Tutorial
  • book.mql4.com
Creation of Custom Indicators - Simple Programs in MQL4 - MQL4 Tutorial
To add comments, please log in or register