Skip to content

Trade Functions

Trade Functions

This is the group of functions intended for managing trading activities.

Trading functions can be used in Expert Advisors and scripts. OrderSend(), OrderClose(), OrderCloseBy(), OrderModify(), OrderDelete() trading functions changing the state of a trading account can be called only if trading by Expert Advisors is allowed (the “Allow live trading” checkbox is enabled in the Expert Advisor or script properties).

Trading can be allowed or prohibited depending on various factors described in the Trade Permission section.

FunctionAction
OrderCloseCloses opened order
OrderCloseByCloses an opened order by another opposite opened order
OrderClosePriceReturns close price of the currently selected order
OrderCloseTimeReturns close time of the currently selected order
OrderCommentReturns comment of the currently selected order
OrderCommissionReturns calculated commission of the currently selected order
OrderDeleteDeletes previously opened pending order
OrderExpirationReturns expiration date of the selected pending order
OrderLotsReturns amount of lots of the selected order
OrderMagicNumberReturns an identifying (magic) number of the currently selected order
OrderModifyModification of characteristics of the previously opened or pending orders
OrderOpenPriceReturns open price of the currently selected order
OrderOpenTimeReturns open time of the currently selected order
OrderPrintPrints information about the selected order in the log
OrderProfitReturns profit of the currently selected order
OrderSelectThe function selects an order for further processing
OrderSendThe main function used to open an order or place a pending order
OrdersHistoryTotalReturns the number of closed orders in the account history loaded into the terminal
OrderStopLossReturns stop loss value of the currently selected order
OrdersTotalReturns the number of market and pending orders
OrderSwapReturns swap value of the currently selected order
OrderSymbolReturns symbol name of the currently selected order
OrderTakeProfitReturns take profit value of the currently selected order
OrderTicketReturns ticket number of the currently selected order
OrderTypeReturns order operation type of the currently selected order

What’s new in MQL5

Added the functions for working with orders, deals and positions to conduct trading operations. An order is a request to buy or sell. The order execution leads to a deal resulting in opening, modifying or closing a position.

If you develop trading robots, pay attention to the new OrderSendAsync function intended for asynchronous trading operations. This function is executed in less than 1 millisecond (it does not wait till the trade server responds to a sent request) and returns control immediately. Low network costs, high Depth of Market refresh rates and asynchronous order sending accelerate trading operations dozens of times. For intraday systems, the speed of trading operations can be a key factor.

Last updated on