Why the Warning, empty controlled statement found?

Back to topics list To post a new topic, please log in or register
avatar
52
renzbub 2015.08.06 13: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); 
   }
     
}

 

avatar
736
honest_knave 2015.08.06 16: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); 
   }
     
}

 

avatar
52
renzbub 2015.08.06 20: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!

Back to topics list  

To add comments, please log in or register