Download MetaTrader 5

EA not respecting variable declaration

To add comments, please log in or register
Marcelo Coutinho
1202
Marcelo Coutinho  

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
5554
Dua Yong Rew  
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
29862
Alain Verleyen  
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