Download MetaTrader 5

EA not respecting variable declaration

To add comments, please log in or register
Trade like successful traders - subscribe to their signals!
Marcelo Coutinho
1151
Marcelo Coutinho 2014.05.11 02:27 

Hi there ! Dummy question maybe but why my EA only works when I make an if() statement with number ?

Thank you ! 

enum YTRD_TIMER
  {
   NAO=1,      // Sem Temporizador
   SIM=2,      // Com Temporizador
  };

input YTRD_TIMER        temporizador=SIM;       // Temporizador

void OnTick()
  {
   MqlDateTime dt;
   TimeCurrent(dt);

   if(temporizador==SIM) *** DOES NOT WORK !
     {
      if(dt.min==minute) // Faz o MT5 trabalhar de minuto em minuto
        {
         return;
        }
      else
        {
         minute=dt.min;
        }
     }

   if(temporizador==2) *** WORKS !
     {
      if(dt.min==minute) // Faz o MT5 trabalhar de minuto em minuto
        {
         return;
        }
      else
        {
         minute=dt.min;
        }
     }
Dua Yong Rew
5423
Dua Yong Rew 2014.05.11 04:36  
YouTrade:

Hi there ! Dummy question maybe but why my EA only works when I make an if() statement with number ?

Thank you ! 

Try use define instead of enum
Alain Verleyen
Moderator
30725
Alain Verleyen 2014.05.11 10:10  
YouTrade:

Hi there ! Dummy question maybe but why my EA only works when I make an if() statement with number ?

Thank you ! 

It should work. Try to remove this "," :

enum YTRD_TIMER
  {
   NAO=1,      // Sem Temporizador
   SIM=2,      // Com Temporizador
  };
To add comments, please log in or register