Download MetaTrader 5

Enumerator compile error

To add comments, please log in or register
Floryn
18
Floryn  

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

Alain Verleyen
Moderator
36700
Alain Verleyen  
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.

Floryn
18
Floryn  
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.
whroeder1
17915
whroeder1  
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

Floryn
18
Floryn  
I understand, thanks a lot for your answers.
To add comments, please log in or register