MQL5 ignores if operator condition and executes code inside if operator

vladimir.zajakin  

Hi!

I have stumbled on a very interesting problem. If operator is executing the code inside if operator even if condition is not fulfilled. Here is the code:

//adx formation type 2
   Print(adx_buffer_slow[4]," ",di_minus_count_good_enough_3," ",di_minus_crossed_adx_down," ",fractal_line_data[0].points_per_bar,
   " ",mean_fractal_line_length);
   
   if(adx_buffer_slow[4]>30 && di_minus_count_good_enough_3 && di_minus_crossed_adx_down 
   && fractal_line_data[0].points_per_bar>mean_fractal_line_length && !sell_paused_market_formation && !buy_paused_market_formation 
   && !excuse_sell_not_allowed_trend && !excuse_buy_not_allowed_trend && !fractal_line_consolidation_detected)
   {
      Print("ADX formation type 2 detected! Sell paused!");
      sell_paused_market_formation=true;
      di_minus_count_good_enough=false;
      di_minus_count_good_enough_3=false;
      //save data for statistics
      market_formation_dates[market_formation_date_index]=TimeCurrent();
      market_formation_date_index++;
      ArrayResize(market_formation_dates,market_formation_date_index+1);
   }

I started to faultfind some strange EA operations, as you can see i print out the the values of variables that participate in if operator just before the if operator is executed. Here are the values that i get when running this EA on backtest:

As you can see adx_buffer_slow[4] value is 14.738.. the two flags have values true and true, line length is 2.52 and mean fractal line length is 17.1. According to the condition in if operator adx_buffer value should be greater than 30 and fractal line length should be greater than mean fractal line length. Obviously 14.738.. is not greater than 30 and 2.52 is not greater than 17.1. So what is happening to if operator? Why is it being executed anyway?


Thanks!

vladimir.zajakin  

Hi!

Looks like the MQL5 client was opened for too long. I commented completely that code block, recompiled and then run again - same result. The code was being executed even when it was commented. Then i realised that something is not ok with terminal itself. So i restarted the computer and then tried again - now it work fine. Sorry to bother. 

Reason: