Hello everyone,
I am currently developing a custom indicator in MQL5 which utilizes multiple Exponential Moving Averages (EMAs). However, I am encountering a parameter count error with the iMA function and need some assistance in resolving it.
The code is intended to calculate four EMAs (5, 10, 20, and 60 periods) and check certain conditions to generate signals. However, when I attempt to compile the script, I receive the following error:
Here is the code:
ema5[i] = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, i);
ema10[i] = iMA(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, i);
ema20[i] = iMA(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, i);
ema60[i] = iMA(NULL, 0, 60, 0, MODE_EMA, PRICE_CLOSE, i);
Error (All 4 EMA facing same error):
'iMA' - wrong parameters count
built-in: int iMA(const string,ENUM_TIMEFRAMES,int,int,ENUM_MA_METHOD,int)
I have tried adjusting the parameters to match the iMA function signature but the error persists. I would appreciate it if someone could help me identify what I am doing wrong or suggest how I might correctly use the iMA function to avoid this error.
Thank you in advance for the help!
ema5[i] = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, i); ema10[i] = iMA(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, i); ema20[i] = iMA(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, i); ema60[i] = iMA(NULL, 0, 60, 0, MODE_EMA, PRICE_CLOSE, i);Those are MT4 calls.
Perhaps you should read the manual, especially the examples.
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.
They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020)
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020)
MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors - MQL5 Articles (2010)
How to call indicators in MQL5 - MQL5 Articles (2010)
Thanks guys for providing all the informative suggestions, currently I have solved the error. Thank you so much
.
Don't do that. Someone searching might find this thread and still be clueless. What was the problem? What solved what?
How To Ask Questions The Smart Way. (2004)
When You Ask.
Follow up with a brief note on the solution.
Why don't you guys post in the correct place?
- www.mql5.com
double emaSlow = iMA(_Symbol, PERIOD_M1, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, 0);
having error
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone,
I am currently developing a custom indicator in MQL5 which utilizes multiple Exponential Moving Averages (EMAs). However, I am encountering a parameter count error with the iMA function and need some assistance in resolving it.
The code is intended to calculate four EMAs (5, 10, 20, and 60 periods) and check certain conditions to generate signals. However, when I attempt to compile the script, I receive the following error:
Here is the code:
ema5[i] = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, i);
ema10[i] = iMA(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, i);
ema20[i] = iMA(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, i);
ema60[i] = iMA(NULL, 0, 60, 0, MODE_EMA, PRICE_CLOSE, i);
Error (All 4 EMA facing same error):
'iMA' - wrong parameters count
built-in: int iMA(const string,ENUM_TIMEFRAMES,int,int,ENUM_MA_METHOD,int)
I have tried adjusting the parameters to match the iMA function signature but the error persists. I would appreciate it if someone could help me identify what I am doing wrong or suggest how I might correctly use the iMA function to avoid this error.
Thank you in advance for the help!