Download MetaTrader 5
To add comments, please log in or register
Make profit on MQL5 services. It's easy!
Wemerson Guimaraes
535
Wemerson Guimaraes 2015.08.30 13:53 

Olá,

 

How can i do to add friendly labels for enum options?

See my code below, i used 2 external parameters with enum: AppliedPrice and TradeMode. The first uses a language native enum (ENUM_APLIED_PRICE)  e the second uses an enum that i created myself (ENUM_TRADE_MODE). 

extern ENUM_APPLIED_PRICE AppliedPrice = PRICE_CLOSE;

enum ENUM_TRADE_MODE{ AGGRESSIVE_MODE, MODERATE_MODE, SAFE_MODE };
extern ENUM_TRADE_MODE TradeMode = MODERATE_MODE;


Now, take a look at the 2 elements on the image below. The ENUM_APLIED_PRICE( AppliedPrice) do not shows its declared enum options(PRICE_CLOSE, PRICE_OPEN, etc) but "friendly" text labels instead. But my custom enum (ENUM_TRADE_MODE) shows its optins (AGGRESSIVE_MODE, MODERATE_MODE, SAFE_MODE):

Enums 

 

How can i do to show friendly texts just like native enums? I've tried some options but not works:

...
// First try, but not works
enum ENUM_TRADE_MODE{ AGGRESSIVE_MODE = "Chuck Norris", MODERATE_MODE = "Gentle Gentleman", SAFE_MODE = "Fluffy Puppy" };

// Then i try, but still not works
enum ENUM_TRADE_MODE{ AGGRESSIVE_MODE "Chuck Norris", MODERATE_MODE "Gentle Gentleman", SAFE_MODE "Fluffy Puppy" };
...
whroeder1
13656
whroeder1 2015.08.30 14:39  
enum ENUM_TRADE_MODE{ AGGRESSIVE_MODE, // Chuck Norris
                      MODERATE_MODE,   // Gentle Gentleman
                      SAFE_MODE};      // Fluffy Puppy
Wemerson Guimaraes
535
Wemerson Guimaraes 2015.08.30 14:51  
WHRoeder:

No way... it's so simple...

Just a small adjustment because the last element not works on your code... 

enum ENUM_TRADE_MODE{ AGGRESSIVE_MODE, // Chuck Norris
                     MODERATE_MODE, // Gentle Gentleman
                     SAFE_MODE // Fluffy Puppy
                     };

 

Thans man... this was great!... i will never think in use comments

/
To add comments, please log in or register