Download MetaTrader 5
To add comments, please log in or register
Interested in earning money via MQL5 Cloud Network? Enter your profile!
Massimo
478
Massimo 2016.07.02 10:38 

Hello guys, I have this problem I can not solve. I wrote this code:

enum Tipo_MM
  {
   A=MODE_SMA,// Media semplice
   B=MODE_EMA,// Media esponenziale
  };
 
input Tipo_MM Tipo_MediaMobile=A;


Then I insert "Tipo_MediaMobile" in this code:


(iMA(NULL,PERIOD_CURRENT,3,0,Tipo_MediaMobile,PRICE_CLOSE,0)


but it gives me this warning:

"improper enumerator cannot be used "

You can help me solve this problem? Thank you all, Max



Muzaffar Ergashaliev
9462
Muzaffar Ergashaliev 2016.11.07 08:35  
input int    MA_Period            = 1; // MA Period
input ENUM_MA_METHOD MA_Method    = 0; // MA Method
input ENUM_APPLIED_PRICE MA_Price = 0; // MA Price

iMA(NULL,PERIOD_CURRENT,MA_Period,0,MA_Method,MA_Price)
Carl Schreiber
5940
Carl Schreiber 2016.07.02 10:55  

Have you read about enum in the editors reference - it helps:

...
After the enumeration is declared, a new integer-valued 4-byte data type appears. ...

Just place the cursors above enum and press F1.

whroeder1
13610
whroeder1 2016.07.02 11:49  

You created the type Tipo_MM as a subset of ENUM_MA_METHOD using the ENUM_MA_METHOD constants. This is fine, although I don't know why you want to reject/disallow the other methods.

But iMA expects a ENUM_MA_METHOD, thus your error. So cast it back to the superset or drop your type and use the ENUM_MA_METHOD as the type of your variable.

iMA(NULL, PERIOD_CURRENT, 3, 0, (ENUM_MA_METHOD) Tipo_MediaMobile, PRICE_CLOSE, 0)
Massimo
478
Massimo 2016.07.02 12:37  
WHRoeder:

You created the type Tipo_MM as a subset of ENUM_MA_METHOD using the ENUM_MA_METHOD constants. This is fine, although I don't know why you want to reject/disallow the other methods.

But iMA expects a ENUM_MA_METHOD, thus your error. So cast it back to the superset or drop your type and use the ENUM_MA_METHOD as the type of your variable.

Thanks WHRoeder, kind as always!
Greetings, Massimo.
/
To add comments, please log in or register