MT4 Enumeration Dilemma

 

I am using the MT4 enumeration for a selection input:

enum ENUM_myChoice { a, b, c, e, f, g };

The problem is if I have to add "d" to the list in alphabetical order, all of my templates using e, f or g are ruined because they are off by 1.

Is there an elegant solution to this or only brute force?

Thanks in Advance

 
Avery Horton:

I am using the MT4 enumeration for a selection input:

enum ENUM_myChoice { a, b, c, e, f, g };

The problem is if I have to add "d" to the list in alphabetical order, all of my templates using e, f or g are ruined because they are off by 1.

Is there an elegant solution to this or only brute force?

Thanks in Advance

Ruined, why ? you used the numerical value ?
 
Avery Horton: The problem is if I have to add "d" to the list in alphabetical order, all of my templates using e, f or g are ruined because they are off by 1.
Keep the numeric values constant, add new values alphabetically.
enum ENUM_myChoice { a, b, c, d=6, e=3, f, g };


Alain Verleyen: Ruined, why ? you used the numerical value ?
A template stores numeric values
Code
extern COUNT               Lookback       = 14;
extern double              EmaSmoothing   = 1.0;
extern ENUM_APPLIED_PRICE  AppliedPrice   = PRICE_CLOSE;
Template
<inputs>
Lookback=14
EmaSmoothing=1.0
AppliedPrice=0
 
Avery Horton:

I am using the MT4 enumeration for a selection input:

enum ENUM_myChoice { a, b, c, e, f, g };

The problem is if I have to add "d" to the list in alphabetical order, all of my templates using e, f or g are ruined because they are off by 1.

Is there an elegant solution to this or only brute force?

Thanks in Advance

If I needed to insert a member and not to affect the previous declaration, I would assign a value to each member.

 enum ENUM_myChoice { a=1, b=2, c=3, e=4, f=5, g=6 };

 enum ENUM_myChoice { a=1, b=2, c=3, d=7,e=4, f=5, g=6 }; 

 
Ovo Cz:

If I needed to insert a member and not to affect the previous declaration, I would assign a value to each member.

 enum ENUM_myChoice { a=1, b=2, c=3, e=4, f=5, g=6 };

 enum ENUM_myChoice { a=1, b=2, c=3, d=7,e=4, f=5, g=6 }; 

Thank you.

That should fix it!

 
Avery Horton: That should fix it!
That won't. Enumerations default to starting at zero. Instead of e-g being off by one, all will be off by one.
See my solution #2
 
whroeder1:

Keep the numeric values constant, add new values alphabetically.
enum ENUM_myChoice { a, b, c, d=6, e=3, f, g };



A template stores numeric values
Code
extern COUNT               Lookback       = 14;
extern double              EmaSmoothing   = 1.0;
extern ENUM_APPLIED_PRICE  AppliedPrice   = PRICE_CLOSE;
Template
<inputs>
Lookback=14
EmaSmoothing=1.0
AppliedPrice=0
Ah this kind of template. Ok Thanks.
 
whroeder1:
That won't. Enumerations default to starting at zero. Instead of e-g being off by one, all will be off by one.
See my solution #2

Understood.  I have NONE=0

 

enum ENUM_myIndicator

{

NONE=0, ATR=1, ATRLEFT=2, ATRZONE=3, AVGRANGE=4, BAR_PATTERN=75, BKOUT=5,

};