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 | |
trailingStopLoss | TrailingStopLoss | distance trailing stop loss configuration | |
volume | number | Yes | position volume |
profit | number | Yes | position cumulative profit, including unrealized profit resulting from currently open position part (except swap and commissions) and realized profit resulting from partially closed position part and including swap and commissions |
realizedProfit | number | Yes | profit of the already closed part, including commissions and swap (realized and unrealized) |
unrealizedProfit | number | Yes | profit of the part of the position which is not yet closed, excluding swap and commissions |
commission | number | Yes | total position commissions, resulting both from currently open and closed position parts |
realizedCommission | number | Yes | position realized commission, resulting from partially closed position part |
unrealizedCommission | number | Yes | position unrealized commission, resulting from currently open position part |
swap | number | Yes | position cumulative swap, including both swap from currently open position part (unrealized swap) and swap from partially closed position part (realized swap) |
realizedSwap | number | Yes | swap from partially closed position part |
unrealizedSwap | number | Yes | swap resulting from currently open position part |
accountCurrencyExchangeRate | number | current exchange rate of account currency into account base currency (USD if you did not override it) | |
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 |
|
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 |
brokerComment | string | current comment value on broker side (possibly overriden by the broker) |
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"
}