Download MetaTrader 5

Question for IF

To add comments, please log in or register
mostafalotfi
185
mostafalotfi  

Dear friends ,

 

i have a question for "if" and it would be great if you help me

 

is it correct to write something like this?

 

if((A1>100 && A2<100) || (B1>100 && B2<100));
Keith Watford
Moderator
9641
Keith Watford  
Yes
mostafalotfi
185
mostafalotfi  
GumRai:
Yes


Thank you, 

 

what about this one? should be ok , right?

if((A1>100 || A2<100) && (B1>100 || B2<100));
Keith Watford
Moderator
9641
Keith Watford  
yes
honest_knave
Moderator
2420
honest_knave  
Regarding the brackets, it might also be worth having a quick read through the precedence rules
Michele Lazzarini
473
Michele Lazzarini  

Use of () is recommended.

You can also write this way to make your code clearer:

if(   ( A1>100 || A2<100 )
   && ( B1>100 || B2<100 ) 
  ) ...
To add comments, please log in or register