Metatrader position#
About#
Contains a position
Fields#
Name | Type | Required | Description |
---|---|---|---|
id | string | Yes | position id (ticket) |
type | string | Yes | position type, enum: POSITION_TYPE_BUY , POSITION_TYPE_SELL . See position types |
symbol | string | Yes | position symbol |
magic | number | Yes | position magic number, identifies the EA which opened the position |
time | string(datetime) | Yes | time position was opened at, in ISO format |
brokerTime | string | Yes | time position was opened at, in broker timezone, YYYY-MM-DD HH:mm:ss.SSS format |
updateTime | string(datetime) | Yes | last position modification time, in ISO format |
openPrice | number | Yes | position open price |
currentPrice | number | Yes | current price |
currentTickValue | number | Yes | current tick value |
stopLoss | number | position stop loss price | |
takeProfit | number | position take profit price | |
volume | number | Yes | position volume |
swap | number | Yes | position cumulative swap |
profit | number | Yes | position cumulative profit including commissions and swap |
comment | string | position 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 |
|
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 |
|
unrealizedProfit | number | Yes | profit of the part of the position which is not yet closed, including swap |
realizedProfit | number | Yes | profit of the already closed part, including commissions and swap |
commission | number | Yes | commission |
reason | string | Yes | position opening reason. See https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties#enum_position_reason enum: POSITION_REASON_CLIENT , POSITION_REASON_EXPERT , POSITION_REASON_MOBILE , POSITION_REASON_WEB , POSITION_REASON_UNKNOWN |
accountCurrencyExchangeRate | number | current exchange rate of account currency into USD | |
originalComment | string | position original comment (present if possible to restore from history) | |
updatePending | boolean | flag indicating that position original comment and clientId was not identified yet and will be updated in a future packet |
Example#
{
"id": "46648037",
"type": "POSITION_TYPE_BUY",
"symbol": "AUDNZD",
"magic": 1000,
"time": "2020-04-17T04:30:03.223Z",
"brokerTime": "2020-04-17 07:30:03.223",
"openPrice": 1.05782,
"currentPrice": 1.05299,
"currentTickValue": 0.59971,
"stopLoss": 0.99877,
"volume": 0.1,
"swap": -0.5,
"profit": -28.96846699999893,
"updateTime": "2020-04-20T08:54:42.119Z",
"commission": -0.5,
"clientId": "AS_AUDNZD_46648037",
"unrealizedProfit": -28.96599299999934,
"realizedProfit": -0.002473999999590859,
"reason": "POSITION_REASON_EXPERT"
}