MetaTrader API
Metatrader 5 api

Trading

Trading functionallity

Send market or pending order

GET
/OrderSend
x-api-key<token>

Your API key

In: header

Query Parameters

idstring

Your Account UUID which you connected via the Dashboard

Default"{{id}}"
symbolstring

Symbol

Default"EURUSD"
operationstring

Buy, Sell, BuyLimit, SellLimit, BuyStop, SellStop

Default"Buy"
Value in"Buy" | "Sell" | "BuyLimit" | "SellLimit" | "BuyStop" | "SellStop" | "BuyStopLimit" | "SellStopLimit" | "CloseBy" | "Balance" | "Credit"
volumenumber

Lots

Default0.1
Formatdouble
price?number

Price. Optional, but required in case of Instant Execution.

Default0
Formatdouble
slippage?integer

Slippage. Optional.

Default0
Formatint64
stoploss?number

StopLoss. Optional.

Default0
Formatdouble
takeprofit?number

TakeProfit. Optional.

Default0
Formatdouble
comment?string

Comment. Optional.

expertID?integer

Custom user field. You can specify any value up to your needs. In MT5 this parameter called 'magic number.'

Default0
Formatint64
stopLimitPrice?number

For the StopLimit order. Optional.

Default0
Formatdouble
expiration?string

Expiration time in yyyy-MM-ddTHH:mm:ss format

Formatdate-time
expirationType?string

Expiration type

Default"Specified"
Value in"GTC" | "Today" | "Specified" | "SpecifiedDay"
placedType?string

Who placed the order

Default"Manually"
Value in"Manually" | "ByExpert" | "ByDealer" | "OnSL" | "OnTP" | "OnStopOut" | "OnRollover" | "OnVmargin" | "Gateway" | "Signal" | "Settlement" | "Transfer" | "Sync" | "ExternalService" | "Migration" | "Mobile" | "Web" | "OnSplit" | "Default"

Response Body

curl -X GET "https://api.metatraderapi.dev/OrderSend?id=%7B%7Bid%7D%7D&symbol=EURUSD&operation=Buy&volume=0.1&price=0&slippage=0&stoploss=0&takeprofit=0&comment=string&expertID=0&stopLimitPrice=0&expiration=2019-08-24T14%3A15%3A22Z&expirationType=GTC&placedType=Manually"
{
  "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"
}

Modify market or pending order

GET
/OrderModify
x-api-key<token>

Your API key

In: header

Query Parameters

idstring

Your Account UUID which you connected via the Dashboard

Default"{{id}}"
ticketinteger

Order ticket

Default0
Formatint64
stoplossnumber

StopLoss.

Default0
Formatdouble
takeprofitnumber

TakeProfit

Default0
Formatdouble
price?number

Price

Default0
Formatdouble
expiration?string

Expiartion in format: yyyy-MM-ddTHH:mm:ss

Formatdate-time
expirationType?string

Expiration type

Default"Specified"
Value in"GTC" | "Today" | "Specified" | "SpecifiedDay"
stoplimit?number

Stop limit price for stop limit orders

Default0
Formatdouble

Response Body

curl -X GET "https://api.metatraderapi.dev/OrderModify?id=%7B%7Bid%7D%7D&ticket=0&stoploss=0&takeprofit=0&price=0&expiration=2019-08-24T14%3A15%3A22Z&expirationType=GTC&stoplimit=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"
}

Close market or pending order

GET
/OrderClose
x-api-key<token>

Your API key

In: header

Query Parameters

idstring

Your Account UUID which you connected via the Dashboard

Default"{{id}}"
ticketinteger

Order ticket

Default0
Formatint64
lots?number

Lots. Optional.

Default0
Formatdouble
price?number

Price. Optional, but required in case of Instant Execution.

Default0
Formatdouble
slippage?integer

Slippage. Optional.

Default0
Formatint64

Response Body

curl -X GET "https://api.metatraderapi.dev/OrderClose?id=%7B%7Bid%7D%7D&ticket=0&lots=0&price=0&slippage=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"
}