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 Placement<br />

• Pool – An optional constant indicating the order pool: pending/open orders, or closed orders.<br />

◦ MODE_TRADES – By default, we are examining the pool of currently opened orders.<br />

◦ MODE_HISTORY – Examines the closed order pool (the order history).<br />

If the OrderSelect() function locates the order successfully, the return value will be true,<br />

otherwise, the return value will be false.<br />

Here's an example of the OrderSelect() function using an order ticket number. The Ticket variable<br />

should contain a valid order ticket:<br />

OrderSelect(Ticket,SELECT_BY_TICKET);<br />

After the OrderSelect() function has been called, we can use any of the order information functions<br />

to retrieve information about that order. A complete listing of functions that can be used with<br />

OrderSelect() can be found in the MQL Reference under Trading Functions. Here's a list of the most<br />

commonly used order information functions:<br />

• OrderSymbol() – The symbol of the instrument that the selected order was placed on.<br />

• OrderType() - The order type of the selected order: buy or sell; market, stop or limit. The<br />

return value is an integer corresponding to the order type constants on page 22.<br />

• OrderOpenPrice() – The opening price of the selected order.<br />

• OrderLots() – The lot size of the selected order.<br />

• OrderStopLoss() – The stop loss price of the selected order.<br />

• OrderTakeProfit() – The take profit price of the selected order.<br />

• OrderTicket() – The ticket number of the selected order. Generally used when cycling<br />

through the order pool with the SELECT_BY_POS parameter.<br />

• OrderMagicNumber() – The magic number of the selected order. When cycling through<br />

orders, you'll need to use this to identify orders placed <strong>by</strong> your EA.<br />

• OrderComment() – The comment that was placed with the order. This can be used as a<br />

secondary order identifier.<br />

• OrderClosePrice() – The closing price of the selected order. The order must already be<br />

closed (i.e. present in the order history pool).<br />

• OrderOpenTime() – The opening time of the selected order.<br />

• OrderCloseTime() – The closing time of the selected order.<br />

33

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

Saved successfully!

Ooh no, something went wrong!