iMA returns indicator handle not indicator value. You may check example available in this link: iMA.

Documentation on MQL5: Technical Indicators / iMA
- www.mql5.com
iMA - Technical Indicators - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Hi
Please check how to use indicators in mql5 – here iMA and iRSI are just handles for indicator calculations, then you can use those handles to copy values from the buffers and obtain the values from the candles you need.
Best Regards

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
Here is the code for this, my RSI always returns as 12 for every symbol i use my script on
Moving averages always return at 10 and 11 as well
I Cannot for the life of me figure out why.
// Calculate Moving Averages correctly
double maShort = iMA(_Symbol, PERIOD_H1, 50, 0, MODE_SMA, PRICE_CLOSE);
double maLong = iMA(_Symbol, PERIOD_H1, 200, 0, MODE_SMA, PRICE_CLOSE);
// Debugging: Print the last price to check data integrity
Print("Last Close Price: ", iClose(Symbol(), PERIOD_H1, 0));
// Calculate RSI correctly
double rsi = iRSI(_Symbol, PERIOD_H1, 14, PRICE_CLOSE);
// Debugging: Detailed prints for Moving Averages and RSI
Print("maShort: ", maShort, ", maLong: ", maLong);
Print("RSI: ", rsi);
// Further Debugging for RSI calculation - print last 14 close prices
Print("Last 14 close prices for RSI calculation:");
for(int i = 0; i < 14; i++) {
double closePrice = iClose(_Symbol, PERIOD_H1, i);
Print("Close price [", i, "]: ", closePrice);
}