string as_string(ENUM_APPLIED_PRICE p, int len=0){ string price_XXX = EnumToString(p); return StringSubstr(price_XXX, 6, len); } string as_string(ENUM_TIMEFRAMES period){ if(period == PERIOD_CURRENT) period = (ENUM_TIMEFRAMES) _Period; string period_xxx = EnumToString(period); // PERIOD_XXX return StringSubstr(period_xxx, 7); // XXX } string as_string(ENUM_MA_METHOD average){ string ave_xxx = EnumToString(average); // MODE_XXX return StringSubstr(ave_xxx, 5); // XXX }
- If the values are contiguous (0,1,2, …) you can use
enum Test {A,B,C}; template<typename T> T end(T value=0){ for(;;++value){ string asT=EnumToString(value); // A, B, C, Test::3 if(StringFind(asT, "::") > 0) return value; } return WRONG_VALUE; } Test t=end<Test>(); Print( EnumToString(--t) ); // C
I wouldn't bother, you know the enumeration. Just #define Test_FIRST A and #define Test_LAST C and be done. For(Test i=Test_FIRST; i <=Test_Last; ++i) … - Non-contiguous would be like Timeframes (1,5,15,30 …) You'll have to roll your own
ENUM_TIMEFRAMES larger(ENUM_TIMEFRAMES tf){ static ENUM_TIMEFRAMES period[]={ PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1, PERIOD_MN1, PERIOD_MN1}; for(int i=0; ;++i) if(period[i] == tf) return period[i+1]; }
whroeder1:
- If the values are contiguous (0,1,2, …) you can useI wouldn't bother, you know the enumeration. Just #define Test_FIRST A and #define Test_LAST C and be done. For(Test i=Test_FIRST; i <=Test_Last; ++i) …
- Non-contiguous would be like Timeframes (1,5,15,30 …) You'll have to roll your own
Thank you for help.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
There is some function to transform an element of an enumerated list in a list or array of strings. For example, when we make an indicator and put an ENUM_APPLIED_PRICE input the program will automatically display a price list in the input parameters. How can I do the same with a button or list view? I know I can do some functions for this. But if you need to do lots of lists this can be cumbersome.