MT4 conditional statement impossibility

 

Consider the following:

if ( t2>0 && (t2>t1 || t2>t3) ) l=5;
I have seen this statement return true when t2<0. It seems to me this should be impossible, unless MT4 is disregarding the parenthesis altoghether. This really shakes a fundamental assumption i had made about mql4. Does anyone know how MT4 hangles logic statements such as this? Do I have to make everything nested?
 

I don't believe you. Please provide actual example of values & proof. e.g.

int t1 = 1;
int t2 = -1;
int t3 = -5;
if ( t2>0 && (t2>t1 || t2>t3) )
 Alert("That\'s not what I was expecting");

(which does not trigger Alert)

 

BTW in light of some other parallel threads running here, I should explain that I'm an analytical type who does test-driven development, so ...

"I don't believe you" does not mean "You are wrong"

It just means that I'm awaiting proof.

 
gatornuke:

Consider the following:

I have seen this statement return true when t2<0. It seems to me this should be impossible, unless MT4 is disregarding the parenthesis altoghether. This really shakes a fundamental assumption i had made about mql4. Does anyone know how MT4 hangles logic statements such as this? Do I have to make everything nested?

Is t2 typecast as an integer? If t2 is a double then t2 of "zero" can actually be >0 in the machine precision representation of the double value zero for t2 at that time.
 

try

Print("t1= ",t1,"t2= ",t2,"t3= ",t3) ;
if ( t2>0 && (t2>t1 || t2>t3) ) 
   {l=5; Print("t2>0 && (t2>t1 || t2>t3) IS TRUE") }
 

You're right. I was printing t1 and t2 instead of t2 and t3. The value of t1 was negative, and i thought it was t2, since I didn't print any labels. I'm glad i don't have to rewrite my whole code.

Reason: