Mql5 update build 3139 some logics are not working

 

why the bool logic is returning a number when i set Percentage_greater_than a small number like 0.001 or even zero ? its so strange...

and when i put this line into a bool variable i get false even though it should be definitely true:


((wick / (body + tail + wick)) >= (Percentage_greater_than / 100))
int Wick_tail_proportion()
  {
   double tail = 0, wick = 0, body = 0;
   if(bar[1].open > bar[1].close)
     {
      wick = bar[1].high - bar[1].open;
      tail = bar[1].close - bar[1].low;
     }
   else
     {
      wick = bar[1].high - bar[1].close;
      tail = bar[1].open - bar[1].low;
     }
     
   body = MathAbs(bar[1].open - bar[1].close);
   if((body + tail + wick) != 0)
     {
      if((tail / (body + tail + wick)) >= (Percentage_greater_than / 100))
         return 0;
      if((wick / (body + tail + wick)) >= (Percentage_greater_than / 100))
         return 1;
     }
   return -1;
  }



 
Khuman Bakhramirad:

why the bool logic is returning a number when i set Percentage_greater_than a small number like 0.001 or even zero ? its so strange...

and when i put this line into a bool variable i get false even though it should be definitely true:



((wick / (body + tail + wick)) >= (Percentage_greater_than / 100))
Showing as double, looks like a bug in the debugger.


Also, never use equality to compare floats/doubles.

https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

if((body + tail + wick) != 0)
This will be 99.99999999% of the time true, it might have other unintended consequences.
 

I also recomend that you create extra variables to avoid repeating the same expression over and over like the:

(body + tail + wick)
 
I confirmed it, it's a bug in the debugger's inspector, the code works thou.
Just cleanup the code, use extra variables and avoid complex expressions in the debugger for now.

 
Alexandre Borela #:
I confirmed it, it's a bug in the debugger's inspector, the code works thou.
Just cleanup the code, use extra variables and avoid complex expressions in the debugger for now.

Thank you so much hope they fix this bug
 
Khuman Bakhramirad #:
Thank you so much hope they fix this bug

If you want a bug to be fixed it's always better to post code that compiles.

Reported to Metaquotes.

 
Thank you for report.
Fixed.