EMA values MT4 vs MT5

 

Hello, 


I just moved from Mql4 to Mql5.


How to get MA value of the last Candle on MT4:

double  iMA(symbol,timeframe,ma_period,ma_shift,ma_method,applied_price,shift);

so I need:

double ema3 = iMA(_Symbol,_Period,3,0,MODE_EMA,PRICE_CLOSE,1);


What I need to get this exact value on a MT5 EA?

Why on MT4 is enough a line of code and on MT5 I need dozens?

 
arimbur: I just moved from Mql4 to Mql5. How to get MA value of the last Candle on MT4: so I need: What I need to get this exact value on a MT5 EA? Why on MT4 is enough a line of code and on MT5 I need dozens?

Forum on trading, automated trading systems and testing trading strategies

Please help me

Fernando Carreiro, 2022.10.03 12:53

That is incorrect! iMA() returns a handle in MQL5, not a value. Only in MQL4 did it return a value, but you are coding in MQL5. Please read up on the documentation and have a look at the example code.

In essence, you should obtain the handle in the OnInit() and then use CopyBuffer() in the other event handlers such as OnCalculate().

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