Download MetaTrader 5

Programmatically get enum value descriptions?

To add comments, please log in or register
Use MQL5 Cloud Network. It is secure!
Erik Dahlstrand
8779
Erik Dahlstrand 2013.11.18 13:35 

Hi,

Is it possible to get enum value descriptions programmatically? I don't mean a switch-case lookup function but a way to programmatically get the description.

Something like this: 

E.g. EnumValueToString(PERIOD_H1) => "1 hour"

Alain Verleyen
Moderator
30775
Alain Verleyen 2013.11.18 15:28  
erdah:

Hi,

Is it possible to get enum value descriptions programmatically? I don't mean a switch-case lookup function but a way to programmatically get the description.

Something like this: 

E.g. EnumValueToString(PERIOD_H1) => "1 day"

   Print(EnumToString(Period()));
Erik Dahlstrand
8779
Erik Dahlstrand 2013.11.18 18:16  
angevoyageur:

Thanks but that 's not what I'm after.

Print(EnumToString(Period())); // => "PERIOD_H1"

 I want something like:

Print(EnumValueToString(Period())); // => "1 hour"
Alain Verleyen
Moderator
30775
Alain Verleyen 2013.11.18 18:21  
erdah:

Thanks but that 's not what I'm after.

 I want something like:

You have to program it then, there is not such thing as a description for timeframe or enum in mql5.
Erik Dahlstrand
8779
Erik Dahlstrand 2013.11.18 18:41  
angevoyageur:
You have to program it then, there is not such thing as a description for timeframe or enum in mql5.

The comment after each enum value is shown instead of the enum value itself in some situations in the terminal and the IDE. For example if you declare ENUM_POS_TYPE as an input parameter to your EA you will be presented with a listbox of Volume and Risk Percentage instead of POS_TYPE_VOLUME and POS_TYPE_RISK.

enum ENUM_POS_TYPE {
  POS_TYPE_VOLUME,  // Volume
  POS_TYPE_RISK     // Risk Percentage
};

I wonder if that data is also accessible from within MQL5.

Alain Verleyen
Moderator
30775
Alain Verleyen 2013.11.18 19:01  
erdah:

The comment after each enum value is shown instead of the enum value itself in some situations in the terminal and the IDE. For example if you declare ENUM_POS_TYPE as an input parameter to your EA you will be presented with a listbox of Volume and Risk Percentage instead of POS_TYPE_VOLUME and POS_TYPE_RISK.

I wonder if that data is also accessible from within MQL5.

I know, but unfortunately not. Of course, it would be possible technically, but Metaquotes doesn't provide a way to do that currently. You can try to make the suggestion to ServiceDesk.
To add comments, please log in or register