MQL4 while Loop Operator
Overview
The while operator executes a specified operator repeatedly as long as a checked expression remains true. The syntax is while(expression) operator;.
Behavior
expression is evaluated before each execution of the operator.expression evaluates to true, the operator is executed.expression evaluates to false.expression is false from the beginning, the operator will not be executed at all.Constraints and Recommendations
IsStopped() function within the loop condition to prevent infinite loops or unresponsive scripts.Syntax
while(expression)
operator;
Example
while(k < n && !IsStopped()) {
y = y * x;
k++;
}
Related Topics
Previous
arrow_back
Switch operator