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.
Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
- www.mql5.com
CopyBuffer - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Thanks Fernando,
Appreciate you pointing me in the right direction!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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