ENUM_MA_METHOD

 

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



 

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.

 

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)
 
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.
 
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)
Reason: