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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

EXPERT ADVISOR PROGRAMMING<br />

Chapter 5<br />

Order Management<br />

You've already been introduced to the OrderSelect() function in chapter 2. In this section, we will<br />

use the OrderSelect() function, along with the cycle operators for and while, to loop through the<br />

order pool and retrieve order information. This method will be used to close multiple orders, add<br />

trailing stops, count the number of open orders, and more.<br />

The Order Loop<br />

The for Operator<br />

The for operator is used to loop through a block of code a predetermined number of times. We<br />

declare an integer variable to use as a counter, and assign it a starting value. We indicate the<br />

condition which, if true, will cause the loop to run. We also indicate an expression <strong>by</strong> which to<br />

increment the counter variable.<br />

Here is an example of a for loop:<br />

for(int Counter = 1; Counter

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

Saved successfully!

Ooh no, something went wrong!