MT4 to MT5 translation problem
In MQL5, the indicator functions do not return buffer data values as you do in MQL4. They return an indicator handle (an int, not a double).
You then have to use that handle with the CopyBuffer function to obtain the buffer data values. Study the example code provided for the iATR function.
int iATR( string symbol, // symbol name ENUM_TIMEFRAMES period, // period int ma_period // averaging period );
Return Value
Returns the handle of a specified technical indicator, in case of failure returns INVALID_HANDLE. The computer memory can be freed from an indicator that is no more utilized, using the IndicatorRelease() function, to which the indicator handle is passed.
- www.mql5.com
Thanks Fernando,
Appreciate you pointing me in the right direction!
Hi,
I'm getting different behaviour in MT5 when I translate the following code:
MT4:
MT5:
For some reason, I do not get the same resulting value in stopLossPrice.
Could anyone please provide some pointers where I might be going wrong here?
Thanks