Hello, I'm trying to make the trader able to set MA type on an EA, I tried this coding:
But when I compile it it says "improper enumerator cannot be used"
How can I fix this? I tried to add the mode id on "" (Simple = "0",...) but then it says "Constant expresion is not intergal" and "MA_Method declatation without type" and "Mode" undeclared identifier.
Any ideas?
Hello, I'm trying to make the trader able to set MA type on an EA, I tried this coding:
But when I compile it it says "improper enumerator cannot be used"
How can I fix this? I tried to add the mode id on "" (Simple = "0",...) but then it says "Constant expresion is not intergal" and "MA_Method declatation without type" and "Mode" undeclared identifier.
Any ideas?
Instead of putting the word "Simple", use the number you assign in the enum. Example: Mode = 0; (Simple),
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon.
You missed the point. OP doesn't want numbers in the input, he want words in the properties box. Zero is meaningless to the code user, Simple is not. Write self-documenting code, don't hard code numbers. | ![]() |
But iMA takes a ENUM_MA_METHOD not a MA_Method. So
- Either use the proper enumeration (ENUM_MA_METHOD) to support all methods
- or if the values are the same cast the value to the proper type. It should be declared as
enum MA_Method // Same as ENUM_MA_METHOD except no SMMA { Simple = MODE_SMA, Exponential = MODE_EMA, // Never any reason to use the SMMA(n) it's equivalent to the EMA(2n-1). // futures.io/ninjatrader-programming/8358-smoothed-moving-average-smma-how-avoid.html" // The Smoothed Moving Average or SMMA - How to Avoid It - NinjaTrader Programming | futures.io LinearWeighted = MODE_LWMA }; input MA_Method Mode = Simple; : double SlowMA = iMA(Symbol(),Period(),SlowMA,0,ENUM_MA_METHOD(Mode),PRICE_CLOSE,1);

- 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, I'm trying to make the trader able to set MA type on an EA, I tried this coding:
But when I compile it it says "improper enumerator cannot be used"
How can I fix this? I tried to add the mode id on "" (Simple = "0",...) but then it says "Constant expresion is not intergal" and "MA_Method declatation without type" and "Mode" undeclared identifier.
Any ideas?