MQL4 Trading Functions

Metatrader 4 (MQL4) forex trading functions include: OrderClose, OrderCloseBy, OrderClosePrice, OrderCloseTime, OrderComment, OrderCommission, OrderDelete, OrderExpiration, OrderLots, OrderMagicNumber, OrderModify, OrderOpenPrice, OrderOpenTime, OrderPrint, OrderProfit, OrderSelect, OrderSend, OrdersHistoryTotal, OrderStopLoss, OrdersTotal, OrderSwap, OrderSymbol, OrderTakeProfit, OrderTicket, and OrderType.

MQL4 Trading Function Listing

OrderClose OrderCloseBy OrderClosePrice

OrderCloseTime OrderComment OrderCommission

OrderDelete OrderExpiration OrderLots

OrderMagicNumber OrderModify OrderOpenPrice

OrderOpenTime OrderPrint OrderProfit

OrderSelect OrderSend OrdersHistoryTotal

OrderStopLoss OrdersTotal OrderSwap

OrderSymbol OrderTakeProfit OrderTicket

OrderType

Trade Operation: OP_BUY, OP_SELL, OP_BUYLIMIT, OP_SELLLIMIT, OP_BUYSTOP, OP_SELLSTOP

The three functions in the General Order Information category are OrderSelect, OrdersHistoryTotal and OrdersTotal. These three functions are used particularly when looping through all open orders and are particularly useful in an order close out routine within MT4 or in routines that attach stop or target prices or that update stop or target prices dynamically, like a trailing stop.

OrderSelect

OrdersHistoryTotal

OrdersTotal

MQL4 Trading Functions: Specific Order Information

Specific Order Information may be acquired for a single open or closed order by first calling the OrderSelect function, followed by the desired specific order information function. For instance, to check on the current stop price for an open trade, the OrderSelect function would first be called, followed by the OrderStopLoss function.

OrderClosePrice

OrderCloseTime

OrderComment

OrderCommission

OrderExpiration

OrderLots

OrderMagicNumber

OrderOpenPrice

OrderOpenTime

OrderPrint

OrderProfit

OrderStopLoss

OrderSwap

OrderSymbol

OrderTakeProfit

OrderTicket

OrderType

The order Placement Trading Functions are the backbone of any MT4 expert advisor or trade script, and may not be called from within a custom indicator. The five Order Placement Trading Functions in MT4 are OrderSend, OrderClose, OrderCloseBy, OrderDelete and OrderModify. These functions allow an expert advisor to create, close, close by offset, delete and modify orders. Metatrader 4 is very sensitive to slight variations in syntax, which may cause the proper execution of an order, or an error and possibly hours of frustration depending on the exact syntax used. To ensure that orders are properly processed and to save the hours of frustration, it is best to start with existing working code and then customize from there.

OrderClose

Follow patrickmwhite on Twitter

For updates