Enumerator compile error

 

Hi,

I'm new in mql programming and trying to develop my first EA based on what I found in mql articles. The scope is learning because I've made backtests but I never got any profit :)

For the code below I get next errors:

'CCI' - enumerator identifier already defined

'Stochastic' - enumerator identifier already defined

'CCIStochastic' - enumerator identifier already defined

enum entryStrategy  
  {
   CCI,           // CCI only
   Stochastic,    // Stochastic only
   CCIStochastic, // CCI + Stochastic 
  };
enum exitStrategy  
  { 
   NoExit,        // No Exit Strategy
   CCI,           // CCI only
   Stochastic,    // Stochastic only
   CCIStochastic, // CCI + Stochastic 
  }; 

I could rename them like entryCCI and exitCCI... is there something else that I could do?

Thanks

 
Floryn:
...

I could rename them like entryCCI and exitCCI... is there something else that I could do?

Thanks

No. You can't use the same identifier more than once.

 
Thanks for your answer. I thought that since the enum names are different (entryStrategy and exitStrategy), the list of their values (identifiers) doesn't count.
 
Floryn: . I thought that since the enum names are different (entryStrategy and exitStrategy), the list of their values (identifiers) doesn't count.

The enum type is different. Since enumerations were first introduced in C, 30+ years ago, the names have always been at global scope.

Most people add a prefix to them related to the type, e.g. EN_CCI and EX_CCI

 
I understand, thanks a lot for your answers.
Reason: