Download MetaTrader 5

Why the Warning, empty controlled statement found?

To add comments, please log in or register
Stephen Reynolds
4362
Stephen Reynolds  

Why does the Warning "empty controlled statement found" come up when using  if(enableCount == true within the following code?

void OnTick()    
{   
   double close = Close[1];  
   datetime time = iTime(NULL,0,1);

   static int barCount = 1;
   static bool enableCount = false;   

             
   if(Close[1] < Open[1]) 
   {
      barCount++;        
   }
   
   if(barCount == 7) 
   {
      enableCount = true; 
   }
   
   if(enableCount == true);
   {   
      ObjectCreate("Buy",OBJ_ARROW_THUMB_UP,0,time,close); 
   }
     
}
honest_knave
Moderator
2333
honest_knave  

Lose the ; at the end of it.

Regarding style, there is no need to write ==true for a bool. 

void OnTick()    
{   
   double close = Close[1];  
   datetime time = iTime(NULL,0,1);

   static int barCount = 1;
   static bool enableCount = false;   

             
   if(Close[1] < Open[1]) 
   {
      barCount++;        
   }
   
   if(barCount == 7) 
   {
      enableCount = true; 
   }
   
//   if(enableCount == true);
   if(enableCount)
   {   
      ObjectCreate("Buy",OBJ_ARROW_THUMB_UP,0,time,close); 
   }
     
}
Stephen Reynolds
4362
Stephen Reynolds  
honest_knave:

Lose the ; at the end of it.

Regarding style, there is no need to write ==true for a bool.  

honest_knave:

Lose the ; at the end of it.

Regarding style, there is no need to write ==true for a bool. 

Thanks for pointing that ; mistake out!

To add comments, please log in or register