25.10.2016 Views

Expert Advisor Programming by Andrew R. Young

Expert Advisor Programming by Andrew R. Young

Expert Advisor Programming by Andrew R. Young

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Order Management<br />

The while Operator<br />

The while operator is a simpler method of looping in MQL. The for loop is best if you know exactly<br />

how many times you plan on executing the loop. If you're unsure of the number of iterations<br />

however, then the while loop would be more appropriate.<br />

Here's an example of a while loop:<br />

while(Something == true)<br />

{<br />

// Loop code<br />

}<br />

This literal example uses a boolean variable called Something. If Something is equal to true, the<br />

loop will execute. Of course, if the value of Something never changes, the loop will run endlessly.<br />

Thus, it is necessary that there be a condition to change the value of Something at some point<br />

during the loop. Once this condition is true, Something is changed to false, and the loop will stop<br />

executing.<br />

You could also increment a variable, just like you would using the for operator:<br />

int Counter = 1;<br />

while(Counter

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!