# Converting from MT4 to MT5 - double iATR( string symbol, int timeframe, int period, int shift)

4668

Hi there,

in MT4 I have this technical indicator:  double iATR( string symbol, int timeframe, int period, int shift

Parameters:

symbol   -   Symbol the data of which should be used to calculate indicator. NULL means the current symbol.

timeframe   -   Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe

period   -   Averaging period for calculation.

shift   -   Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

Sample:

if(iATR(NULL,0,12,4)>iATR(NULL,0,20,3)) return(0);

in MT5 there is no shift i.e. handle=iATR(name,period,atr_period);

int  iATR(

string           symbol,        // symbol name

ENUM_TIMEFRAMES  period,        // period

int              ma_period      // averaging period

);

How do I implement this shift in MT5 if this is the code that I want to convert from MT4  is   if(iATR(NULL,0,12,4)>iATR(NULL,0,20,3)) return(0);

Documentation on MQL5: Standard Constants, Enumerations and Structures / Chart Constants / Chart Timeframes
• www.mql5.com
Standard Constants, Enumerations and Structures / Chart Constants / Chart Timeframes - Documentation on MQL5
1863

waterhorse:

Hi there,

in MT4 I have this technical indicator:  double iATR( string symbol, int timeframe, int period, int shift

in MT5 there is no shift i.e. handle=iATR(name,period,atr_period);

How do I implement this shift in MT5 if this is the code that I want to convert from MT4  is   if(iATR(NULL,0,12,4)>iATR(NULL,0,20,3)) return(0);

Hi waterhorse,

You're right, ask for it at Service Desk then.

If we want to shift ATR to the left, then assign value to the previous bar. I.e, shift one bar to the left, instead assign ATR value to bar 0 we assign value to bar 1. However I have no idea if we have shift to the right, i.e. how to assign latest ATR value to the right side :( ?.

:D

Hi waterhorse,

Just checking again. You may have to create ATR CI and use PlotSetIndexInteger() (click that) using ENUM_PLOT_PROPERTY_INTEGER's PLOT_SHIFT (click that).

I skip read those - lol.

:D

6496

Have you read Timeseries and Indicators Access section?

Actually working with indicators data in MQL5 is differents to MQL4. iATR function creates a handle. To get indicator values you should use CopyBuffer function.

4668

alexvd:

Have you read Timeseries and Indicators Access section?

Actually working with indicators data in MQL5 is differents to MQL4. iATR function creates a handle. To get indicator values you should use CopyBuffer function.