MetaTrader API
Metatrader 5 api

Order History

Order history functions

Order history

GET
/OrderHistory
x-api-key<token>

Your API key

In: header

Query Parameters

idstring

Your Account UUID which you connected via the Dashboard

Default"{{id}}"
fromstring

'From date' in format: yyyy-MM-ddTHH:mm:ss

Default"2022-01-01T00:00:00"
tostring

'To date' in format: yyyy-MM-ddTHH:mm:ss

Default"2022-09-01T00:00:00"
sort?string

Sort by open time or close time

Default"OpenTime"
Value in"OpenTime" | "CloseTime"
ascending?boolean

Ascending sort

Defaulttrue
filter?array<string>

List of fields that need to return. If not specified - all fields.

Response Body

curl -X GET "https://api.metatraderapi.dev/OrderHistory?id=%7B%7Bid%7D%7D&from=2022-01-01T00%3A00%3A00&to=2022-09-01T00%3A00%3A00&sort=OpenTime&ascending=true&filter=string"
{
  "orders": [
    {
      "ticket": 0,
      "profit": 0.1,
      "swap": 0.1,
      "commission": 0.1,
      "fee": 0.1,
      "closePrice": 0.1,
      "closeTime": "2019-08-24T14:15:22Z",
      "closeLots": 0.1,
      "closeComment": "string",
      "openPrice": 0.1,
      "openTime": "2019-08-24T14:15:22Z",
      "lots": 0.1,
      "contractSize": 0.1,
      "expertId": 0,
      "placedType": "Manually",
      "orderType": "Buy",
      "dealType": "DealBuy",
      "symbol": "string",
      "comment": "string",
      "state": "Started",
      "stopLoss": 0.1,
      "takeProfit": 0.1,
      "requestId": 0,
      "digits": 0,
      "profitRate": 0.1,
      "stopLimitPrice": 0.1,
      "dealInternalIn": {
        "ticketNumber": 0,
        "id": "string",
        "login": 0,
        "historyTime": 0,
        "orderTicket": 0,
        "openTime": 0,
        "symbol": "string",
        "type": "DealBuy",
        "direction": "In",
        "openPrice": 0.1,
        "price": 0.1,
        "stopLoss": 0.1,
        "takeProfit": 0.1,
        "volume": 0,
        "profit": 0.1,
        "profitRate": 0.1,
        "volumeRate": 0.1,
        "commission": 0.1,
        "fee": 0.1,
        "swap": 0.1,
        "expertId": 0,
        "positionTicket": 0,
        "comment": "string",
        "contractSize": 0.1,
        "digits": 0,
        "moneyDigits": 0,
        "freeProfit": 0.1,
        "trailRounder": 0.1,
        "openTimeMs": 0,
        "placedType": "Manually",
        "openTimeAsDateTime": "2019-08-24T14:15:22Z",
        "lots": 0.1
      },
      "dealInternalOut": {
        "ticketNumber": 0,
        "id": "string",
        "login": 0,
        "historyTime": 0,
        "orderTicket": 0,
        "openTime": 0,
        "symbol": "string",
        "type": "DealBuy",
        "direction": "In",
        "openPrice": 0.1,
        "price": 0.1,
        "stopLoss": 0.1,
        "takeProfit": 0.1,
        "volume": 0,
        "profit": 0.1,
        "profitRate": 0.1,
        "volumeRate": 0.1,
        "commission": 0.1,
        "fee": 0.1,
        "swap": 0.1,
        "expertId": 0,
        "positionTicket": 0,
        "comment": "string",
        "contractSize": 0.1,
        "digits": 0,
        "moneyDigits": 0,
        "freeProfit": 0.1,
        "trailRounder": 0.1,
        "openTimeMs": 0,
        "placedType": "Manually",
        "openTimeAsDateTime": "2019-08-24T14:15:22Z",
        "lots": 0.1
      },
      "orderInternal": {
        "ticketNumber": 0,
        "id": "string",
        "login": 0,
        "symbol": "string",
        "historyTime": 0,
        "openTime": 0,
        "expirationTime": 0,
        "executionTime": 0,
        "type": "Buy",
        "fillPolicy": "FillOrKill",
        "expirationType": "GTC",
        "placedType": "Manually",
        "openPrice": 0.1,
        "stopLimitPrice": 0.1,
        "price": 0.1,
        "stopLoss": 0.1,
        "takeProfit": 0.1,
        "volume": 0,
        "requestVolume": 0,
        "state": "Started",
        "expertId": 0,
        "dealTicket": 0,
        "comment": "string",
        "contractSize": 0.1,
        "digits": 0,
        "baseDigits": 0,
        "profitRate": 0.1,
        "openTimeMs": 0,
        "ticket": 0,
        "executionTimeAsDateTime": "2019-08-24T14:15:22Z",
        "lots": 0.1,
        "requestLots": 0.1,
        "openTimeMsAsDateTime": "2019-08-24T14:15:22Z",
        "openTimeAsDateTime": "2019-08-24T14:15:22Z"
      },
      "partialCloseDeals": [
        {
          "ticketNumber": 0,
          "id": "string",
          "login": 0,
          "historyTime": 0,
          "orderTicket": 0,
          "openTime": 0,
          "symbol": "string",
          "type": "DealBuy",
          "direction": "In",
          "openPrice": 0.1,
          "price": 0.1,
          "stopLoss": 0.1,
          "takeProfit": 0.1,
          "volume": 0,
          "profit": 0.1,
          "profitRate": 0.1,
          "volumeRate": 0.1,
          "commission": 0.1,
          "fee": 0.1,
          "swap": 0.1,
          "expertId": 0,
          "positionTicket": 0,
          "comment": "string",
          "contractSize": 0.1,
          "digits": 0,
          "moneyDigits": 0,
          "freeProfit": 0.1,
          "trailRounder": 0.1,
          "openTimeMs": 0,
          "placedType": "Manually",
          "openTimeAsDateTime": "2019-08-24T14:15:22Z",
          "lots": 0.1
        }
      ],
      "partialFillDeals": [
        {
          "ticketNumber": 0,
          "id": "string",
          "login": 0,
          "historyTime": 0,
          "orderTicket": 0,
          "openTime": 0,
          "symbol": "string",
          "type": "DealBuy",
          "direction": "In",
          "openPrice": 0.1,
          "price": 0.1,
          "stopLoss": 0.1,
          "takeProfit": 0.1,
          "volume": 0,
          "profit": 0.1,
          "profitRate": 0.1,
          "volumeRate": 0.1,
          "commission": 0.1,
          "fee": 0.1,
          "swap": 0.1,
          "expertId": 0,
          "positionTicket": 0,
          "comment": "string",
          "contractSize": 0.1,
          "digits": 0,
          "moneyDigits": 0,
          "freeProfit": 0.1,
          "trailRounder": 0.1,
          "openTimeMs": 0,
          "placedType": "Manually",
          "openTimeAsDateTime": "2019-08-24T14:15:22Z",
          "lots": 0.1
        }
      ],
      "closeVolume": 0,
      "volume": 0,
      "expirationType": "GTC",
      "expirationTime": "2019-08-24T14:15:22Z",
      "fillPolicy": "FillOrKill",
      "openTimestampUTC": 0,
      "closeTimestampUTC": 0
    }
  ],
  "internalDeals": [
    {
      "ticketNumber": 0,
      "id": "string",
      "login": 0,
      "historyTime": 0,
      "orderTicket": 0,
      "openTime": 0,
      "symbol": "string",
      "type": "DealBuy",
      "direction": "In",
      "openPrice": 0.1,
      "price": 0.1,
      "stopLoss": 0.1,
      "takeProfit": 0.1,
      "volume": 0,
      "profit": 0.1,
      "profitRate": 0.1,
      "volumeRate": 0.1,
      "commission": 0.1,
      "fee": 0.1,
      "swap": 0.1,
      "expertId": 0,
      "positionTicket": 0,
      "comment": "string",
      "contractSize": 0.1,
      "digits": 0,
      "moneyDigits": 0,
      "freeProfit": 0.1,
      "trailRounder": 0.1,
      "openTimeMs": 0,
      "placedType": "Manually",
      "openTimeAsDateTime": "2019-08-24T14:15:22Z",
      "lots": 0.1
    }
  ],
  "internalOrders": [
    {
      "ticketNumber": 0,
      "id": "string",
      "login": 0,
      "symbol": "string",
      "historyTime": 0,
      "openTime": 0,
      "expirationTime": 0,
      "executionTime": 0,
      "type": "Buy",
      "fillPolicy": "FillOrKill",
      "expirationType": "GTC",
      "placedType": "Manually",
      "openPrice": 0.1,
      "stopLimitPrice": 0.1,
      "price": 0.1,
      "stopLoss": 0.1,
      "takeProfit": 0.1,
      "volume": 0,
      "requestVolume": 0,
      "state": "Started",
      "expertId": 0,
      "dealTicket": 0,
      "comment": "string",
      "contractSize": 0.1,
      "digits": 0,
      "baseDigits": 0,
      "profitRate": 0.1,
      "openTimeMs": 0,
      "ticket": 0,
      "executionTimeAsDateTime": "2019-08-24T14:15:22Z",
      "lots": 0.1,
      "requestLots": 0.1,
      "openTimeMsAsDateTime": "2019-08-24T14:15:22Z",
      "openTimeAsDateTime": "2019-08-24T14:15:22Z"
    }
  ],
  "action": 0,
  "partialResponse": true
}
{
  "message": "string",
  "code": "DONE",
  "stackTrace": "string"
}

Pending order history

GET
/PendingOrderHistory
x-api-key<token>

Your API key

In: header

Query Parameters

idstring

Your Account UUID which you connected via the Dashboard

Default"{{id}}"
fromstring

'From date' in format: yyyy-MM-ddTHH:mm:ss

Default"2023-09-01T00:00:00"
tostring

'To date' in format: yyyy-MM-ddTHH:mm:ss

Default"2023-10-01T00:00:00"
sort?string

Sort by open time or close time

Default"OpenTime"
Value in"OpenTime" | "CloseTime"
ascending?boolean

Ascending sort

Defaulttrue

Response Body

curl -X GET "https://api.metatraderapi.dev/PendingOrderHistory?id=%7B%7Bid%7D%7D&from=2023-09-01T00%3A00%3A00&to=2023-10-01T00%3A00%3A00&sort=OpenTime&ascending=true"
[
  {
    "ticketNumber": 0,
    "id": "string",
    "login": 0,
    "symbol": "string",
    "historyTime": 0,
    "openTime": 0,
    "expirationTime": 0,
    "executionTime": 0,
    "type": "Buy",
    "fillPolicy": "FillOrKill",
    "expirationType": "GTC",
    "placedType": "Manually",
    "openPrice": 0.1,
    "stopLimitPrice": 0.1,
    "price": 0.1,
    "stopLoss": 0.1,
    "takeProfit": 0.1,
    "volume": 0,
    "requestVolume": 0,
    "state": "Started",
    "expertId": 0,
    "dealTicket": 0,
    "comment": "string",
    "contractSize": 0.1,
    "digits": 0,
    "baseDigits": 0,
    "profitRate": 0.1,
    "openTimeMs": 0,
    "ticket": 0,
    "executionTimeAsDateTime": "2019-08-24T14:15:22Z",
    "lots": 0.1,
    "requestLots": 0.1,
    "openTimeMsAsDateTime": "2019-08-24T14:15:22Z",
    "openTimeAsDateTime": "2019-08-24T14:15:22Z"
  }
]
{
  "message": "string",
  "code": "DONE",
  "stackTrace": "string"
}

Order history

GET
/OrderHistoryPagination
x-api-key<token>

Your API key

In: header

Query Parameters

idstring

Your Account UUID which you connected via the Dashboard

Default"{{id}}"
fromstring

'From date' in format: yyyy-MM-ddTHH:mm:ss

Default"2022-01-01T00:00:00"
tostring

'To date' in format: yyyy-MM-ddTHH:mm:ss

Default"2022-09-01T00:00:00"
ordersPerPageinteger

Orders per page

Default10
Formatint32
pageNumberinteger

Page index, starts from 0.

Default0
Formatint32
requestAgain?boolean

If need to force refresh orders from mt5 server

Defaultfalse
sort?string

Sort by open time or close time

Default"OpenTime"
Value in"OpenTime" | "CloseTime"
ascending?boolean

Ascending sort

Defaulttrue
tickets?array<integer>

List of tickets that need to return. If not specified - returns all tickets.

ignoreDepositWithdraw?boolean

Do not return deposit and withdraw operations

Defaultfalse

Response Body

curl -X GET "https://api.metatraderapi.dev/OrderHistoryPagination?id=%7B%7Bid%7D%7D&from=2022-01-01T00%3A00%3A00&to=2022-09-01T00%3A00%3A00&ordersPerPage=10&pageNumber=0&requestAgain=false&sort=OpenTime&ascending=true&tickets=0&ignoreDepositWithdraw=false"
{
  "pagesCount": 0,
  "pageNumber": 0,
  "orders": [
    {
      "ticket": 0,
      "profit": 0.1,
      "swap": 0.1,
      "commission": 0.1,
      "fee": 0.1,
      "closePrice": 0.1,
      "closeTime": "2019-08-24T14:15:22Z",
      "closeLots": 0.1,
      "closeComment": "string",
      "openPrice": 0.1,
      "openTime": "2019-08-24T14:15:22Z",
      "lots": 0.1,
      "contractSize": 0.1,
      "expertId": 0,
      "placedType": "Manually",
      "orderType": "Buy",
      "dealType": "DealBuy",
      "symbol": "string",
      "comment": "string",
      "state": "Started",
      "stopLoss": 0.1,
      "takeProfit": 0.1,
      "requestId": 0,
      "digits": 0,
      "profitRate": 0.1,
      "stopLimitPrice": 0.1,
      "dealInternalIn": {
        "ticketNumber": 0,
        "id": "string",
        "login": 0,
        "historyTime": 0,
        "orderTicket": 0,
        "openTime": 0,
        "symbol": "string",
        "type": "DealBuy",
        "direction": "In",
        "openPrice": 0.1,
        "price": 0.1,
        "stopLoss": 0.1,
        "takeProfit": 0.1,
        "volume": 0,
        "profit": 0.1,
        "profitRate": 0.1,
        "volumeRate": 0.1,
        "commission": 0.1,
        "fee": 0.1,
        "swap": 0.1,
        "expertId": 0,
        "positionTicket": 0,
        "comment": "string",
        "contractSize": 0.1,
        "digits": 0,
        "moneyDigits": 0,
        "freeProfit": 0.1,
        "trailRounder": 0.1,
        "openTimeMs": 0,
        "placedType": "Manually",
        "openTimeAsDateTime": "2019-08-24T14:15:22Z",
        "lots": 0.1
      },
      "dealInternalOut": {
        "ticketNumber": 0,
        "id": "string",
        "login": 0,
        "historyTime": 0,
        "orderTicket": 0,
        "openTime": 0,
        "symbol": "string",
        "type": "DealBuy",
        "direction": "In",
        "openPrice": 0.1,
        "price": 0.1,
        "stopLoss": 0.1,
        "takeProfit": 0.1,
        "volume": 0,
        "profit": 0.1,
        "profitRate": 0.1,
        "volumeRate": 0.1,
        "commission": 0.1,
        "fee": 0.1,
        "swap": 0.1,
        "expertId": 0,
        "positionTicket": 0,
        "comment": "string",
        "contractSize": 0.1,
        "digits": 0,
        "moneyDigits": 0,
        "freeProfit": 0.1,
        "trailRounder": 0.1,
        "openTimeMs": 0,
        "placedType": "Manually",
        "openTimeAsDateTime": "2019-08-24T14:15:22Z",
        "lots": 0.1
      },
      "orderInternal": {
        "ticketNumber": 0,
        "id": "string",
        "login": 0,
        "symbol": "string",
        "historyTime": 0,
        "openTime": 0,
        "expirationTime": 0,
        "executionTime": 0,
        "type": "Buy",
        "fillPolicy": "FillOrKill",
        "expirationType": "GTC",
        "placedType": "Manually",
        "openPrice": 0.1,
        "stopLimitPrice": 0.1,
        "price": 0.1,
        "stopLoss": 0.1,
        "takeProfit": 0.1,
        "volume": 0,
        "requestVolume": 0,
        "state": "Started",
        "expertId": 0,
        "dealTicket": 0,
        "comment": "string",
        "contractSize": 0.1,
        "digits": 0,
        "baseDigits": 0,
        "profitRate": 0.1,
        "openTimeMs": 0,
        "ticket": 0,
        "executionTimeAsDateTime": "2019-08-24T14:15:22Z",
        "lots": 0.1,
        "requestLots": 0.1,
        "openTimeMsAsDateTime": "2019-08-24T14:15:22Z",
        "openTimeAsDateTime": "2019-08-24T14:15:22Z"
      },
      "partialCloseDeals": [
        {
          "ticketNumber": 0,
          "id": "string",
          "login": 0,
          "historyTime": 0,
          "orderTicket": 0,
          "openTime": 0,
          "symbol": "string",
          "type": "DealBuy",
          "direction": "In",
          "openPrice": 0.1,
          "price": 0.1,
          "stopLoss": 0.1,
          "takeProfit": 0.1,
          "volume": 0,
          "profit": 0.1,
          "profitRate": 0.1,
          "volumeRate": 0.1,
          "commission": 0.1,
          "fee": 0.1,
          "swap": 0.1,
          "expertId": 0,
          "positionTicket": 0,
          "comment": "string",
          "contractSize": 0.1,
          "digits": 0,
          "moneyDigits": 0,
          "freeProfit": 0.1,
          "trailRounder": 0.1,
          "openTimeMs": 0,
          "placedType": "Manually",
          "openTimeAsDateTime": "2019-08-24T14:15:22Z",
          "lots": 0.1
        }
      ],
      "partialFillDeals": [
        {
          "ticketNumber": 0,
          "id": "string",
          "login": 0,
          "historyTime": 0,
          "orderTicket": 0,
          "openTime": 0,
          "symbol": "string",
          "type": "DealBuy",
          "direction": "In",
          "openPrice": 0.1,
          "price": 0.1,
          "stopLoss": 0.1,
          "takeProfit": 0.1,
          "volume": 0,
          "profit": 0.1,
          "profitRate": 0.1,
          "volumeRate": 0.1,
          "commission": 0.1,
          "fee": 0.1,
          "swap": 0.1,
          "expertId": 0,
          "positionTicket": 0,
          "comment": "string",
          "contractSize": 0.1,
          "digits": 0,
          "moneyDigits": 0,
          "freeProfit": 0.1,
          "trailRounder": 0.1,
          "openTimeMs": 0,
          "placedType": "Manually",
          "openTimeAsDateTime": "2019-08-24T14:15:22Z",
          "lots": 0.1
        }
      ],
      "closeVolume": 0,
      "volume": 0,
      "expirationType": "GTC",
      "expirationTime": "2019-08-24T14:15:22Z",
      "fillPolicy": "FillOrKill",
      "openTimestampUTC": 0,
      "closeTimestampUTC": 0
    }
  ]
}
{
  "message": "string",
  "code": "DONE",
  "stackTrace": "string"
}

Order history

GET
/HistoryDealsByPositionId
x-api-key<token>

Your API key

In: header

Query Parameters

idstring

Your Account UUID which you connected via the Dashboard

Default"{{id}}"
ticketinteger

Position ticket number

Default0
Formatint64

Response Body

curl -X GET "https://api.metatraderapi.dev/HistoryDealsByPositionId?id=%7B%7Bid%7D%7D&ticket=0"
[
  {
    "ticketNumber": 0,
    "id": "string",
    "login": 0,
    "historyTime": 0,
    "orderTicket": 0,
    "openTime": 0,
    "symbol": "string",
    "type": "DealBuy",
    "direction": "In",
    "openPrice": 0.1,
    "price": 0.1,
    "stopLoss": 0.1,
    "takeProfit": 0.1,
    "volume": 0,
    "profit": 0.1,
    "profitRate": 0.1,
    "volumeRate": 0.1,
    "commission": 0.1,
    "fee": 0.1,
    "swap": 0.1,
    "expertId": 0,
    "positionTicket": 0,
    "comment": "string",
    "contractSize": 0.1,
    "digits": 0,
    "moneyDigits": 0,
    "freeProfit": 0.1,
    "trailRounder": 0.1,
    "openTimeMs": 0,
    "placedType": "Manually",
    "openTimeAsDateTime": "2019-08-24T14:15:22Z",
    "lots": 0.1
  }
]
{
  "message": "string",
  "code": "DONE",
  "stackTrace": "string"
}

Get history positons by ticket numbers with caching

GET
/HistoryPositions
x-api-key<token>

Your API key

In: header

Query Parameters

idstring

Your Account UUID which you connected via the Dashboard

Default"{{id}}"
tickets?array<integer>

Ticket list of positions that you need

Response Body

curl -X GET "https://api.metatraderapi.dev/HistoryPositions?id=%7B%7Bid%7D%7D&tickets=0"
[
  {
    "ticket": 0,
    "profit": 0.1,
    "swap": 0.1,
    "commission": 0.1,
    "fee": 0.1,
    "closePrice": 0.1,
    "closeTime": "2019-08-24T14:15:22Z",
    "closeLots": 0.1,
    "closeComment": "string",
    "openPrice": 0.1,
    "openTime": "2019-08-24T14:15:22Z",
    "lots": 0.1,
    "contractSize": 0.1,
    "expertId": 0,
    "placedType": "Manually",
    "orderType": "Buy",
    "dealType": "DealBuy",
    "symbol": "string",
    "comment": "string",
    "state": "Started",
    "stopLoss": 0.1,
    "takeProfit": 0.1,
    "requestId": 0,
    "digits": 0,
    "profitRate": 0.1,
    "stopLimitPrice": 0.1,
    "dealInternalIn": {
      "ticketNumber": 0,
      "id": "string",
      "login": 0,
      "historyTime": 0,
      "orderTicket": 0,
      "openTime": 0,
      "symbol": "string",
      "type": "DealBuy",
      "direction": "In",
      "openPrice": 0.1,
      "price": 0.1,
      "stopLoss": 0.1,
      "takeProfit": 0.1,
      "volume": 0,
      "profit": 0.1,
      "profitRate": 0.1,
      "volumeRate": 0.1,
      "commission": 0.1,
      "fee": 0.1,
      "swap": 0.1,
      "expertId": 0,
      "positionTicket": 0,
      "comment": "string",
      "contractSize": 0.1,
      "digits": 0,
      "moneyDigits": 0,
      "freeProfit": 0.1,
      "trailRounder": 0.1,
      "openTimeMs": 0,
      "placedType": "Manually",
      "openTimeAsDateTime": "2019-08-24T14:15:22Z",
      "lots": 0.1
    },
    "dealInternalOut": {
      "ticketNumber": 0,
      "id": "string",
      "login": 0,
      "historyTime": 0,
      "orderTicket": 0,
      "openTime": 0,
      "symbol": "string",
      "type": "DealBuy",
      "direction": "In",
      "openPrice": 0.1,
      "price": 0.1,
      "stopLoss": 0.1,
      "takeProfit": 0.1,
      "volume": 0,
      "profit": 0.1,
      "profitRate": 0.1,
      "volumeRate": 0.1,
      "commission": 0.1,
      "fee": 0.1,
      "swap": 0.1,
      "expertId": 0,
      "positionTicket": 0,
      "comment": "string",
      "contractSize": 0.1,
      "digits": 0,
      "moneyDigits": 0,
      "freeProfit": 0.1,
      "trailRounder": 0.1,
      "openTimeMs": 0,
      "placedType": "Manually",
      "openTimeAsDateTime": "2019-08-24T14:15:22Z",
      "lots": 0.1
    },
    "orderInternal": {
      "ticketNumber": 0,
      "id": "string",
      "login": 0,
      "symbol": "string",
      "historyTime": 0,
      "openTime": 0,
      "expirationTime": 0,
      "executionTime": 0,
      "type": "Buy",
      "fillPolicy": "FillOrKill",
      "expirationType": "GTC",
      "placedType": "Manually",
      "openPrice": 0.1,
      "stopLimitPrice": 0.1,
      "price": 0.1,
      "stopLoss": 0.1,
      "takeProfit": 0.1,
      "volume": 0,
      "requestVolume": 0,
      "state": "Started",
      "expertId": 0,
      "dealTicket": 0,
      "comment": "string",
      "contractSize": 0.1,
      "digits": 0,
      "baseDigits": 0,
      "profitRate": 0.1,
      "openTimeMs": 0,
      "ticket": 0,
      "executionTimeAsDateTime": "2019-08-24T14:15:22Z",
      "lots": 0.1,
      "requestLots": 0.1,
      "openTimeMsAsDateTime": "2019-08-24T14:15:22Z",
      "openTimeAsDateTime": "2019-08-24T14:15:22Z"
    },
    "partialCloseDeals": [
      {
        "ticketNumber": 0,
        "id": "string",
        "login": 0,
        "historyTime": 0,
        "orderTicket": 0,
        "openTime": 0,
        "symbol": "string",
        "type": "DealBuy",
        "direction": "In",
        "openPrice": 0.1,
        "price": 0.1,
        "stopLoss": 0.1,
        "takeProfit": 0.1,
        "volume": 0,
        "profit": 0.1,
        "profitRate": 0.1,
        "volumeRate": 0.1,
        "commission": 0.1,
        "fee": 0.1,
        "swap": 0.1,
        "expertId": 0,
        "positionTicket": 0,
        "comment": "string",
        "contractSize": 0.1,
        "digits": 0,
        "moneyDigits": 0,
        "freeProfit": 0.1,
        "trailRounder": 0.1,
        "openTimeMs": 0,
        "placedType": "Manually",
        "openTimeAsDateTime": "2019-08-24T14:15:22Z",
        "lots": 0.1
      }
    ],
    "partialFillDeals": [
      {
        "ticketNumber": 0,
        "id": "string",
        "login": 0,
        "historyTime": 0,
        "orderTicket": 0,
        "openTime": 0,
        "symbol": "string",
        "type": "DealBuy",
        "direction": "In",
        "openPrice": 0.1,
        "price": 0.1,
        "stopLoss": 0.1,
        "takeProfit": 0.1,
        "volume": 0,
        "profit": 0.1,
        "profitRate": 0.1,
        "volumeRate": 0.1,
        "commission": 0.1,
        "fee": 0.1,
        "swap": 0.1,
        "expertId": 0,
        "positionTicket": 0,
        "comment": "string",
        "contractSize": 0.1,
        "digits": 0,
        "moneyDigits": 0,
        "freeProfit": 0.1,
        "trailRounder": 0.1,
        "openTimeMs": 0,
        "placedType": "Manually",
        "openTimeAsDateTime": "2019-08-24T14:15:22Z",
        "lots": 0.1
      }
    ],
    "closeVolume": 0,
    "volume": 0,
    "expirationType": "GTC",
    "expirationTime": "2019-08-24T14:15:22Z",
    "fillPolicy": "FillOrKill",
    "openTimestampUTC": 0,
    "closeTimestampUTC": 0
  }
]
{
  "message": "string",
  "code": "DONE",
  "stackTrace": "string"
}

Get history positons with caching

GET
/HistoryPositionsByCloseTime
x-api-key<token>

Your API key

In: header

Query Parameters

idstring

Your Account UUID which you connected via the Dashboard

Default"{{id}}"
fromstring

'From date' in format: yyyy-MM-ddTHH:mm:ss

Default"2023-09-01T00:00:00"
tostring

'To date' in format: yyyy-MM-ddTHH:mm:ss

Default"2023-10-01T00:00:00"

Response Body

curl -X GET "https://api.metatraderapi.dev/HistoryPositionsByCloseTime?id=%7B%7Bid%7D%7D&from=2023-09-01T00%3A00%3A00&to=2023-10-01T00%3A00%3A00"
[
  {
    "ticket": 0,
    "profit": 0.1,
    "swap": 0.1,
    "commission": 0.1,
    "fee": 0.1,
    "closePrice": 0.1,
    "closeTime": "2019-08-24T14:15:22Z",
    "closeLots": 0.1,
    "closeComment": "string",
    "openPrice": 0.1,
    "openTime": "2019-08-24T14:15:22Z",
    "lots": 0.1,
    "contractSize": 0.1,
    "expertId": 0,
    "placedType": "Manually",
    "orderType": "Buy",
    "dealType": "DealBuy",
    "symbol": "string",
    "comment": "string",
    "state": "Started",
    "stopLoss": 0.1,
    "takeProfit": 0.1,
    "requestId": 0,
    "digits": 0,
    "profitRate": 0.1,
    "stopLimitPrice": 0.1,
    "dealInternalIn": {
      "ticketNumber": 0,
      "id": "string",
      "login": 0,
      "historyTime": 0,
      "orderTicket": 0,
      "openTime": 0,
      "symbol": "string",
      "type": "DealBuy",
      "direction": "In",
      "openPrice": 0.1,
      "price": 0.1,
      "stopLoss": 0.1,
      "takeProfit": 0.1,
      "volume": 0,
      "profit": 0.1,
      "profitRate": 0.1,
      "volumeRate": 0.1,
      "commission": 0.1,
      "fee": 0.1,
      "swap": 0.1,
      "expertId": 0,
      "positionTicket": 0,
      "comment": "string",
      "contractSize": 0.1,
      "digits": 0,
      "moneyDigits": 0,
      "freeProfit": 0.1,
      "trailRounder": 0.1,
      "openTimeMs": 0,
      "placedType": "Manually",
      "openTimeAsDateTime": "2019-08-24T14:15:22Z",
      "lots": 0.1
    },
    "dealInternalOut": {
      "ticketNumber": 0,
      "id": "string",
      "login": 0,
      "historyTime": 0,
      "orderTicket": 0,
      "openTime": 0,
      "symbol": "string",
      "type": "DealBuy",
      "direction": "In",
      "openPrice": 0.1,
      "price": 0.1,
      "stopLoss": 0.1,
      "takeProfit": 0.1,
      "volume": 0,
      "profit": 0.1,
      "profitRate": 0.1,
      "volumeRate": 0.1,
      "commission": 0.1,
      "fee": 0.1,
      "swap": 0.1,
      "expertId": 0,
      "positionTicket": 0,
      "comment": "string",
      "contractSize": 0.1,
      "digits": 0,
      "moneyDigits": 0,
      "freeProfit": 0.1,
      "trailRounder": 0.1,
      "openTimeMs": 0,
      "placedType": "Manually",
      "openTimeAsDateTime": "2019-08-24T14:15:22Z",
      "lots": 0.1
    },
    "orderInternal": {
      "ticketNumber": 0,
      "id": "string",
      "login": 0,
      "symbol": "string",
      "historyTime": 0,
      "openTime": 0,
      "expirationTime": 0,
      "executionTime": 0,
      "type": "Buy",
      "fillPolicy": "FillOrKill",
      "expirationType": "GTC",
      "placedType": "Manually",
      "openPrice": 0.1,
      "stopLimitPrice": 0.1,
      "price": 0.1,
      "stopLoss": 0.1,
      "takeProfit": 0.1,
      "volume": 0,
      "requestVolume": 0,
      "state": "Started",
      "expertId": 0,
      "dealTicket": 0,
      "comment": "string",
      "contractSize": 0.1,
      "digits": 0,
      "baseDigits": 0,
      "profitRate": 0.1,
      "openTimeMs": 0,
      "ticket": 0,
      "executionTimeAsDateTime": "2019-08-24T14:15:22Z",
      "lots": 0.1,
      "requestLots": 0.1,
      "openTimeMsAsDateTime": "2019-08-24T14:15:22Z",
      "openTimeAsDateTime": "2019-08-24T14:15:22Z"
    },
    "partialCloseDeals": [
      {
        "ticketNumber": 0,
        "id": "string",
        "login": 0,
        "historyTime": 0,
        "orderTicket": 0,
        "openTime": 0,
        "symbol": "string",
        "type": "DealBuy",
        "direction": "In",
        "openPrice": 0.1,
        "price": 0.1,
        "stopLoss": 0.1,
        "takeProfit": 0.1,
        "volume": 0,
        "profit": 0.1,
        "profitRate": 0.1,
        "volumeRate": 0.1,
        "commission": 0.1,
        "fee": 0.1,
        "swap": 0.1,
        "expertId": 0,
        "positionTicket": 0,
        "comment": "string",
        "contractSize": 0.1,
        "digits": 0,
        "moneyDigits": 0,
        "freeProfit": 0.1,
        "trailRounder": 0.1,
        "openTimeMs": 0,
        "placedType": "Manually",
        "openTimeAsDateTime": "2019-08-24T14:15:22Z",
        "lots": 0.1
      }
    ],
    "partialFillDeals": [
      {
        "ticketNumber": 0,
        "id": "string",
        "login": 0,
        "historyTime": 0,
        "orderTicket": 0,
        "openTime": 0,
        "symbol": "string",
        "type": "DealBuy",
        "direction": "In",
        "openPrice": 0.1,
        "price": 0.1,
        "stopLoss": 0.1,
        "takeProfit": 0.1,
        "volume": 0,
        "profit": 0.1,
        "profitRate": 0.1,
        "volumeRate": 0.1,
        "commission": 0.1,
        "fee": 0.1,
        "swap": 0.1,
        "expertId": 0,
        "positionTicket": 0,
        "comment": "string",
        "contractSize": 0.1,
        "digits": 0,
        "moneyDigits": 0,
        "freeProfit": 0.1,
        "trailRounder": 0.1,
        "openTimeMs": 0,
        "placedType": "Manually",
        "openTimeAsDateTime": "2019-08-24T14:15:22Z",
        "lots": 0.1
      }
    ],
    "closeVolume": 0,
    "volume": 0,
    "expirationType": "GTC",
    "expirationTime": "2019-08-24T14:15:22Z",
    "fillPolicy": "FillOrKill",
    "openTimestampUTC": 0,
    "closeTimestampUTC": 0
  }
]
{
  "message": "string",
  "code": "DONE",
  "stackTrace": "string"
}