MQL4 Reference 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.

Function

Action

OrderClose

Closes opened order

OrderCloseBy

Closes an opened order by another opposite opened order

OrderClosePrice

Returns close price of the currently selected order

OrderCloseTime

Returns close time of the currently selected order

OrderComment

Returns comment of the currently selected order

OrderCommission

Returns calculated commission of the currently selected order

OrderDelete

Deletes previously opened pending order

OrderExpiration

Returns expiration date of the selected pending order

OrderLots

Returns amount of lots of the selected order

OrderMagicNumber

Returns an identifying (magic) number of the currently selected order

OrderModify

Modification of characteristics of the previously opened or pending orders

OrderOpenPrice

Returns open price of the currently selected order

OrderOpenTime

Returns open time of the currently selected order

OrderPrint

Prints information about the selected order in the log

OrderProfit

Returns profit of the currently selected order

OrderSelect

The function selects an order for further processing

OrderSend

The main function used to open an order or place a pending order

OrdersHistoryTotal

Returns the number of closed orders in the account history loaded into the terminal

OrderStopLoss

Returns stop loss value of the currently selected order

OrdersTotal

Returns the number of market and pending orders

OrderSwap

Returns swap value of the currently selected order

OrderSymbol

Returns symbol name of the currently selected order

OrderTakeProfit

Returns take profit value of the currently selected order

OrderTicket

Returns ticket number of the currently selected order

OrderType

Returns order operation type of the currently selected order