Enumered lists

 
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.
 

I find the function EnumToString.

Now how to obtain the size of an enum list an make a loop to translate all elements of an same list?

 
  1. 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
    }
    
  2. 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) …

  3. 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:
  1. 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) …

  2. Non-contiguous would be like Timeframes (1,5,15,30 …) You'll have to roll your own

Thank you for help.