Expert Advisor Programming by Andrew R. Young
Expert Advisor Programming by Andrew R. Young
Expert Advisor Programming by Andrew R. Young
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Tips and Tricks<br />
Using Order Comments As an Identifier<br />
We've been using the "magic number" as an order identifier that uniquely identifies orders as being<br />
placed <strong>by</strong> a particular expert advisor. If your expert advisor places multiple orders at one time, and<br />
you want to be able to handle each of those orders differently, you can use the order comment as an<br />
optional identifier.<br />
For example, lets say your expert advisor will place two types of orders. You want to be able to<br />
modify or close these orders separately. You'll want to use two OrderSend() functions and place a<br />
different order comment with each one. Then, when selecting orders using the order loop in chapter<br />
5, you'll use OrderComment() as one of the conditions for locating orders to modify or close.<br />
string OrderComment1 = "First order";<br />
string OrderComment2 = "Second order";<br />
// Order placement<br />
int Ticket1 = OrderSend(Symbol(),OP_BUY,LotSize,OpenPrice,UseSlippage,BuyStopLoss,<br />
BuyTakeProfit,OrderComment1,MagicNumber,0,Green);<br />
int Ticket2 = OrderSend(Symbol(),OP_BUY,LotSize,OpenPrice,UseSlippage,BuyStopLoss,<br />
BuyTakeProfit,OrderComment2,MagicNumber,0,Green);<br />
// Order modification<br />
for(int Counter = 0; Counter