MQL4 Boolean Operations
Logical Negation (!)
TRUE (1) if operand is FALSE (0); FALSE (0) if operand is non-zero.if(!a) Print("not 'a'");Logical Operation OR (||)
x, y.TRUE (1) if x or y is true (non-null). FALSE (0) otherwise.if(x<0 || x>=max_bars) Print("out of range");Logical Operation AND (&&)
x, y.TRUE (1) if both x and y are true (non-null). FALSE (0) otherwise.Brief Estimate of Boolean Operations
&& Example:** If the left operand is FALSE, the right operand is not evaluated.|| Example:** If the left operand is TRUE, the right operand is not evaluated.**Code Example for Brief Estimate:**
void OnStart() {
// && example
if(func_false() && func_true()) {
Print("Operation &&: You will never see this expression");
} else {
Print("Operation &&: Result of the first expression is false, so the second wasn't calculated");
} // || example
if(!func_false() || !func_true()) {
Print("Operation ||: Result of the first expression is true, so the second wasn't calculated");
} else {
Print("Operation ||: You will never see this expression");
}
}
bool func_false() {
Print("Function func_false()");
return(false);
}
bool func_true() {
Print("Function func_true()");
return(true);
}
**See also:**