Metatrader order history#
About#
Contains an open order or a history order (completed order)
Fields#
Name | Type | Required | Description |
---|---|---|---|
id | string | Yes | order id (ticket) |
type | string | Yes | order type, enum: ORDER_TYPE_SELL , ORDER_TYPE_BUY , ORDER_TYPE_BUY_LIMIT , ORDER_TYPE_SELL_LIMIT , ORDER_TYPE_BUY_STOP , ORDER_TYPE_SELL_STOP , ORDER_TYPE_BUY_STOP_LIMIT , ORDER_TYPE_SELL_STOP_LIMIT , ORDER_TYPE_CLOSE_BY . See order types |
state | string | Yes | order state, enum: ORDER_STATE_STARTED , ORDER_STATE_PLACED , ORDER_STATE_CANCELED , ORDER_STATE_PARTIAL , ORDER_STATE_FILLED , ORDER_STATE_REJECTED , ORDER_STATE_EXPIRED , ORDER_STATE_REQUEST_ADD , ORDER_STATE_REQUEST_MODIFY , ORDER_STATE_REQUEST_CANCEL . See order states |
magic | number | Yes | order magic number, identifies the EA which created the order |
time | string(datetime) | Yes | time order was created at, in ISO format |
brokerTime | string | Yes | time order was created at, in broker timezone, YYYY-MM-DD HH:mm:ss.SSS format |
doneTime | string(datetime) | time order was executed or canceled at, in ISO format. Will be specified for completed orders only | |
doneBrokerTime | string | time order was executed or canceled at, in broker timezone, YYYY-MM-DD HH:mm:ss.SSS format | |
symbol | string | Yes | order symbol |
openPrice | number | order open price. Required for pending orders | |
stopLimitPrice | number | the Limit order price for the StopLimit order | |
currentPrice | number | current price. Filled for pending orders only. Not filled for history orders. | |
stopLoss | number | order stop loss price | |
takeProfit | number | order take profit price | |
trailingStopLoss | TrailingStopLoss | distance trailing stop loss configuration | |
volume | number | Yes | order requested quantity |
currentVolume | number | Yes | order remaining quantity, i.e. requested quantity - filled quantity |
positionId | string | order position id. Present only if the order has a position attached to it | |
comment | string | order comment. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
brokerComment | string | current comment value on broker side (possibly overriden by the broker) | |
clientId | string | client-assigned id. The id value can be assigned when submitting a trade and will be present on position, history orders and history deals related to the trade. You can use this field to bind your trades to objects in your application and then track trade progress. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
platform | string | Yes | platform id, enum: mt4 , mt5 |
reason | string | Yes | order opening reason. See https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties#enum_order_reason. enum: ORDER_REASON_CLIENT , ORDER_REASON_MOBILE , ORDER_REASON_WEB , ORDER_REASON_EXPERT , ORDER_REASON_SL , ORDER_REASON_TP , ORDER_REASON_SO , ORDER_REASON_UNKNOWN |
fillingMode | string | Yes | order filling mode. See https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties#enum_order_type_filling. enum: ORDER_FILLING_FOK , ORDER_FILLING_IOC , ORDER_FILLING_RETURN |
expirationType | string | Yes | order expiration type. See https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties#enum_order_type_time. enum: ORDER_TIME_GTC , ORDER_TIME_DAY , ORDER_TIME_SPECIFIED , ORDER_TIME_SPECIFIED_DAY |
expirationTime | datetime | order expiration time | |
accountCurrencyExchangeRate | number | current exchange rate of account currency into account base currency (USD if you did not override it) | |
closeByPositionId | string | identifier of an opposite position used for closing by order ORDER_TYPE_CLOSE_BY |
Example#
{
"id": "47067192",
"type": "ORDER_TYPE_BUY_LIMIT",
"state": "ORDER_STATE_PLACED",
"symbol": "AUDNZD",
"magic": 123456,
"time": "2020-04-21T07:39:18.904Z",
"brokerTime": "2020-04-21 10:39:18.904",
"openPrice": 1.05235,
"currentPrice": 1.05335,
"platform": "mt5",
"volume": 0.01,
"currentVolume": 0.01
}