Download MetaTrader 5

The operator "or"

To add comments, please log in or register
ForexTrader17
1041
ForexTrader17  

While using "or" for say 5 statements, if the first or second return true will MQL4 still check all 5?

Thank you. 

honest_knave
Moderator
2319
honest_knave  

No.

From MetaTrader 4 Trading Terminal build 600 with Updated MQL4 Language and Market of Applications Released:

  • Shortened conditions check is now used in logical operations, unlike the old MQL4 version where all expressions have been calculated and the check has been performed afterwards. Suppose there is a check of two conditions with the use of logical AND
      if(condition1 && condition2)
        {
         // some block of operations
        }
    If condition1 expression is false, calculation of condition2 expression is not performed, as false && true result is still equal to false.
To add comments, please log in or register