For example, if you use the functions "SymbolInfoInteger(Symbol(),SYMBOL_SWAP_ROLLOVER3DAYS)" and "MarketInfo(Symbol(),MODE_SWAPTYPE)", you'll get the integer that is not easy to understand.
Is there a existing function or an easy way to translate the integer back to the enum identifier or description that is easy to understand?
Please don't suggest to add code to translate them as you know this post is made for better solution.
ENUM_TIMEFRAMES tf = (ENUM_TIMEFRAMES) _Period;
ENUM_TIMEFRAMES tf = ENUM_TIMEFRAMES(_Period);
The question was "symbolInfoInteger(Symbol(),SYMBOL_SWAP_ROLLOVER3DAYS)" and "MarketInfo(Symbol(),MODE_SWAPTYPE)" The first returns an integer, the second a double. How are you going to use a "Enum list?"
Does this make sense to you?
int anInt = symbolInfoInteger(Symbol(),SYMBOL_SWAP_ROLLOVER3DAYS);
if( anInt == FRIDAY ) ?
ENUM_DAY_OF_WEEK RO3D = ENUM_DAY_OF_WEEK ( symbolInfoInteger(Symbol(),SYMBOL_SWAP_ROLLOVER3DAYS) );
if( RO3D == FRIDAY ) ?
WHRoeder already explained for SYMBOL_SWAP_ROLLOVER3DAYS
For the other, if it's just to make the code easier to read, you could use #define
#define POINTS 0
#define BASE_CURRENCY 1
#define INTEREST 2
#define MARGIN_CURRENCY 3
https://docs.mql4.com/basis/types/integer/enumeration shows this to be true, but it also shows how to create a list of items when using that type. When used in conjunction with the Switch operator, it allows control branching based on constants, which the list within the enum type statement are created as. I am sure that this is not the only possible use for an enum list, but it shows that it is not needed to use the integer value related to each enum list item. The enum part refers to the specific title or name of the list, but within that list is still identifiers associated with that enumerated type.
I am seeing the items inside that header as an enumerated list, which is what I thought OP was asking about. Or do they want the integer that is associated with the specific enum title of the list?
To add comments, please log in or register