MQL4 Reference Language Basics Operators Conditional Operator if-else
If-Else Conditional OperatorThe IF - ELSE operator is used when a choice must be made. Formally, the syntax is as follows:
If the expression is true, operator1 is executed and control is given to the operator that follows operator2 (operator2 is not executed). If the expression is false, operator2 is executed. The else part of the if operator can be omitted. Thus, a divergence may appear in nested if operators with omitted else part. In this case, else addresses to the nearest previous if operator in the same block that has no else part. Examples:
See also Initialization of Variables, Visibility Scope and Lifetime of Variables, Creating and Deleting Objects |