MetaTrader API
Metatrader 4 api

Trading

Connection handling

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" | "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
Formatint32
stoploss?number

StopLoss. Optional.

Default0
Formatdouble
takeprofit?number

TakeProfit. Optional.

Default0
Formatdouble
comment?string

Comment. Optional.

magic?integer

Magic. Optional.

Default0
Formatint32
expiration?string

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

Formatdate-time
placedType?string

Placed type

Default"Client"
Value in"Client" | "Expert" | "Dealer" | "Signal" | "Gateway" | "Mobile" | "Web" | "Api" | "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&magic=0&expiration=2019-08-24T14%3A15%3A22Z&placedType=Client"
{
  "ticket": 0,
  "openTime": "2019-08-24T14:15:22Z",
  "closeTime": "2019-08-24T14:15:22Z",
  "expiration": "2019-08-24T14:15:22Z",
  "type": "Buy",
  "lots": 0.1,
  "symbol": "string",
  "openPrice": 0.1,
  "stopLoss": 0.1,
  "takeProfit": 0.1,
  "closePrice": 0.1,
  "magicNumber": 0,
  "swap": 0.1,
  "commission": 0.1,
  "comment": "string",
  "profit": 0.1,
  "rateOpen": 0.1,
  "rateClose": 0.1,
  "rateMargin": 0.1,
  "ex": {
    "order": 0,
    "login": 0,
    "symbol": "string",
    "digits": 0,
    "cmd": 0,
    "volume": 0,
    "open_time": 0,
    "state": 0,
    "open_price": 0.1,
    "sl": 0.1,
    "tp": 0.1,
    "close_time": 0,
    "value_date": 0,
    "expiration": 0,
    "place_type": 0,
    "conv_rates": [
      0.1
    ],
    "commission": 0.1,
    "commission_agent": 0.1,
    "storage": 0.1,
    "close_price": 0.1,
    "profit": 0.1,
    "taxes": 0.1,
    "magic": 0,
    "comment": "string",
    "internal_id": 0,
    "activation": 0,
    "spread": 0,
    "margin_rate": 0.1,
    "timestamp": 0,
    "reserved": [
      0
    ],
    "next": 0
  },
  "placedType": "Client",
  "state": "OPEN_NORMAL",
  "digits": 0
}
{
  "message": "string",
  "code": "INTERNAL_ERROR",
  "stackTrace": "string"
}

Modify market or pending order

Returns an Order object

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
Formatint32
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

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"
{
  "ticket": 0,
  "openTime": "2019-08-24T14:15:22Z",
  "closeTime": "2019-08-24T14:15:22Z",
  "expiration": "2019-08-24T14:15:22Z",
  "type": "Buy",
  "lots": 0.1,
  "symbol": "string",
  "openPrice": 0.1,
  "stopLoss": 0.1,
  "takeProfit": 0.1,
  "closePrice": 0.1,
  "magicNumber": 0,
  "swap": 0.1,
  "commission": 0.1,
  "comment": "string",
  "profit": 0.1,
  "rateOpen": 0.1,
  "rateClose": 0.1,
  "rateMargin": 0.1,
  "ex": {
    "order": 0,
    "login": 0,
    "symbol": "string",
    "digits": 0,
    "cmd": 0,
    "volume": 0,
    "open_time": 0,
    "state": 0,
    "open_price": 0.1,
    "sl": 0.1,
    "tp": 0.1,
    "close_time": 0,
    "value_date": 0,
    "expiration": 0,
    "place_type": 0,
    "conv_rates": [
      0.1
    ],
    "commission": 0.1,
    "commission_agent": 0.1,
    "storage": 0.1,
    "close_price": 0.1,
    "profit": 0.1,
    "taxes": 0.1,
    "magic": 0,
    "comment": "string",
    "internal_id": 0,
    "activation": 0,
    "spread": 0,
    "margin_rate": 0.1,
    "timestamp": 0,
    "reserved": [
      0
    ],
    "next": 0
  },
  "placedType": "Client",
  "state": "OPEN_NORMAL",
  "digits": 0
}
{
  "message": "string",
  "code": "INTERNAL_ERROR",
  "stackTrace": "string"
}

Close market order with opposite market order

GET
/OrderCloseBy
x-api-key<token>

Your API key

In: header

Query Parameters

idstring

Your Account UUID which you connected via the Dashboard

Default"{{id}}"
ticket1integer

Order ticket

Default0
Formatint32
ticket2integer

Order ticket

Default0
Formatint32

Response Body

curl -X GET "https://api.metatraderapi.dev/OrderCloseBy?id=%7B%7Bid%7D%7D&ticket1=0&ticket2=0"
"string"
{
  "message": "string",
  "code": "INTERNAL_ERROR",
  "stackTrace": "string"
}

Delete pending order

GET
/OrderDelete
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
Formatint32

Response Body

curl -X GET "https://api.metatraderapi.dev/OrderDelete?id=%7B%7Bid%7D%7D&ticket=0"
"string"
{
  "message": "string",
  "code": "INTERNAL_ERROR",
  "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
Formatint32
lots?number

Lots

Default0
Formatdouble
price?number

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

Default0
Formatdouble
slippage?integer

Slippage. Optional.

Default0
Formatint32

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,
  "openTime": "2019-08-24T14:15:22Z",
  "closeTime": "2019-08-24T14:15:22Z",
  "expiration": "2019-08-24T14:15:22Z",
  "type": "Buy",
  "lots": 0.1,
  "symbol": "string",
  "openPrice": 0.1,
  "stopLoss": 0.1,
  "takeProfit": 0.1,
  "closePrice": 0.1,
  "magicNumber": 0,
  "swap": 0.1,
  "commission": 0.1,
  "comment": "string",
  "profit": 0.1,
  "rateOpen": 0.1,
  "rateClose": 0.1,
  "rateMargin": 0.1,
  "ex": {
    "order": 0,
    "login": 0,
    "symbol": "string",
    "digits": 0,
    "cmd": 0,
    "volume": 0,
    "open_time": 0,
    "state": 0,
    "open_price": 0.1,
    "sl": 0.1,
    "tp": 0.1,
    "close_time": 0,
    "value_date": 0,
    "expiration": 0,
    "place_type": 0,
    "conv_rates": [
      0.1
    ],
    "commission": 0.1,
    "commission_agent": 0.1,
    "storage": 0.1,
    "close_price": 0.1,
    "profit": 0.1,
    "taxes": 0.1,
    "magic": 0,
    "comment": "string",
    "internal_id": 0,
    "activation": 0,
    "spread": 0,
    "margin_rate": 0.1,
    "timestamp": 0,
    "reserved": [
      0
    ],
    "next": 0
  },
  "placedType": "Client",
  "state": "OPEN_NORMAL",
  "digits": 0
}
{
  "message": "string",
  "code": "INTERNAL_ERROR",
  "stackTrace": "string"
}