MQL4/MQL5

 

Hello,

How can I write this MQL4 code in MQL5?

     for(int r=1; r<11 ; r++)
        ATR_SUM=ATR_SUM+(iATR(Symbol(),Period(),14,r));
     ATR_TP=(ATR_SUM/10);    

in MQL4 there is shift parameter which is not on MQL5!

MQL4:

double  iATR(
   string       symbol,     // symbol
   int          timeframe,  // timeframe
   int          period,     // averaging period
   int          shift       // shift
   );

MQL5: 

int  iATR(
   string           symbol,        // symbol name
   ENUM_TIMEFRAMES  period,        // period
   int              ma_period      // averaging period 
   ); 

 

it can help you 

https://www.mql5.com/en/docs/indicators/iatr 

Documentation on MQL5: Technical Indicators / iATR
Documentation on MQL5: Technical Indicators / iATR
  • www.mql5.com
Technical Indicators / iATR - Reference on algorithmic/automated trading language for MetaTrader 5
 

Thank you Aleksei, but I did not get anything:(

what happened to shift parameter? how can I calculate something about a candle in the past?

 
Farhad Bafkar:

Thank you Aleksei, but I did not get anything:(

what happened to shift parameter? how can I calculate something about a candle in the past?

I have the same problem. Do you know at this tiem how to manage the lack of the shift in the functions?
 
EugenBenno:
I have the same problem. Do you know at this tiem how to manage the lack of the shift in the functions?

In MQL5, iATR (and any of the i... indicator functions) returns an int handle. You need to apply this handle to the CopyBuffer() function, see documentation link. Here you will also specify the shift.

Reason: