Download MetaTrader 5

Why the Warning, empty controlled statement found?

To add comments, please log in or register
Added support for the Spanish language. Come and check it out!
Stephen Reynolds
2054
Stephen Reynolds 2015.08.06 11:59 

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
2236
honest_knave 2015.08.06 14:55  

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
2054
Stephen Reynolds 2015.08.06 18:47  
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