Expert Advisor Programming by Andrew R. Young
Expert Advisor Programming by Andrew R. Young
Expert Advisor Programming by Andrew R. Young
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Tips and Tricks<br />
We use the OrdInt variable to increment the order count in the order comment. The first order<br />
comment will be "Buy Order 1", the next will be "Buy Order 2" and so on. The OrderSend() function<br />
places the order with the appropriate stop loss and take profit value, using the Count variable to<br />
select the relevant array element.<br />
This is just one way of handling multiple orders, although it is probably the most efficient. The main<br />
drawback to this approach is that we can only calculate stop loss and take profit prices for a limited<br />
number of orders. Alternately, we could scale the take profit and stop loss values <strong>by</strong> a specified<br />
amount, and place a potentially unlimited number of orders:<br />
extern int StopLossStart = 20;<br />
extern int StopLossIncr = 20;<br />
extern int TakeProfitStart = 40;<br />
extern int TakeProfitIncr = 40;<br />
extern int MaxOrders = 5;<br />
In the above example, the stop loss for our first order will be 20 pips. We will increment the stop loss<br />
<strong>by</strong> 20 pips for each additional order. Same for the take profit, except we will start at 40 and<br />
increment <strong>by</strong> 40. Instead of using arrays, we will calculate the stop loss and take profit in the for<br />
loop:<br />
for(int Count = 0; Count