CPlugin

MT5 v2 :: Trade Operations

API v2 (current) · MT5 · 14 operations · base URL https://cloud.mywebapi.com · OpenAPI v2 (JSON) · Redoc

Every call needs Authorization: Bearer $TOKEN — an OAuth 2.0 client-credentials token from https://auth.cplugin.net/connect/token (scope webapi). $TRADE_PLATFORM_ID is the id of a trade platform registered in Toolbox.

Operations

Open the queue of trade requests for dealing

POST /api/v2/MT5/{tradePlatform}/DealerStart

Subscribes the connection to the queue of trade requests of the trade server and loads the requests already waiting in it. From that moment the queue can be read and the requests can be taken for processing — by this connection only, and the subscription lives until the queue is closed or the connection is lost.

The call does not take a request and does not answer one: it only enables the queue. Repeating it on a connection whose queue is already open is harmless.

Timeout: 15 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: The operation may still be completed by the server (X-Request-Outcome: unknown): check its result before repeating it.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 15 s (change). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/DealerStart" \
  -H "Authorization: Bearer $TOKEN"

Close the queue of trade requests

POST /api/v2/MT5/{tradePlatform}/DealerStop

Stops dealing on the connection: the queue is no longer read or taken from, and the requests waiting in it stay in the queue for other dealers. Requests already taken for processing are not returned to the queue — they must still be answered.

The queue applies to the whole connection to the trade platform, so closing it affects every call that reads or takes requests from it. Repeating the call is harmless.

Timeout: 15 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: The operation may still be completed by the server (X-Request-Outcome: unknown): check its result before repeating it.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 15 s (change). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/DealerStop" \
  -H "Authorization: Bearer $TOKEN"

Take the first request of the queue for processing

POST /api/v2/MT5/{tradePlatform}/DealerGet

Takes the request at the head of the queue and reserves it for this connection: the trade server will not hand it to another dealer and waits for the answer. The request must be answered with DealerAnswer; an unanswered request is not returned to the queue and is lost.

The call is a write, not a read for all practical purposes: it changes the state of the queue and cannot be safely repeated — a repeated call takes the next request. When the queue is empty the platform answers MT_RET_OK_NONE. The queue must be opened with DealerStart first.

Timeout: 15 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: The operation may still be completed by the server (X-Request-Outcome: unknown): check its result before repeating it.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 15 s (change). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/DealerGet" \
  -H "Authorization: Bearer $TOKEN"

Take a request with the given identifier for processing

POST /api/v2/MT5/{tradePlatform}/DealerLock/{id}

Reserves the request with the given identifier for this connection, exactly as DealerGet does for the head of the queue, and returns it. The request must be answered with DealerAnswer; an unanswered request is not returned to the queue and is lost.

MT_RET_OK_NONE means that the request is no longer available: it has already been taken by another dealer or has been processed. The queue must be opened with DealerStart first.

Timeout: 15 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: The operation may still be completed by the server (X-Request-Outcome: unknown): check its result before repeating it.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
id path integer (int32) yes Identifier of the trade request.
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 15 s (change). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/DealerLock/$ID" \
  -H "Authorization: Bearer $TOKEN"

Answer the trade request taken for processing

POST /api/v2/MT5/{tradePlatform}/DealerAnswer

Completes the request taken with DealerGet or DealerLock: the confirmation carries the answer code and, depending on the request, the confirmed volume, price and the identifiers of the order and the deal created in an external trading system. The request is processed by the trade server immediately and cannot be answered twice.

The identifier in the confirmation is the identifier of the original request, not the caller-side one. The queue must be opened with DealerStart first. A rejected answer is returned as the platform error that explains it, and the request then stays for the platform to expire.

Timeout: 5 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: The operation may still be completed by the server (X-Request-Outcome: unknown): check its result before repeating it.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 5 s (trade operation). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Request body

MT5Confirm (application/json) — Answer to the trade request.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/DealerAnswer" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "id": 0, "retCode": "Ok", "volume": 0, "price": 0, "tickBid": 0, "tickAsk": 0 }'

Get a trade request by identifier

GET /api/v2/MT5/{tradePlatform}/RequestGet/{id}

Returns the trade request with the given identifier as it is known to the connection, without taking it for processing: the request stays in the queue and can still be handled by any dealer. Use DealerLock to reserve it for an answer.

The queue must be opened with DealerStart first. An identifier that is not in the queue is answered with the platform code that states it.

Timeout: 30 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
id path integer (int32) yes Identifier of the trade request.
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 30 s (history or report). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Responses

Example

curl "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/RequestGet/$ID" \
  -H "Authorization: Bearer $TOKEN"

List the trade requests waiting in the queue

GET /api/v2/MT5/{tradePlatform}/RequestGetAll

Returns the requests waiting in the queue as one list, in the order the trade server keeps them. Reading does not take a request for processing and does not change the queue; requests already taken by a dealer are not part of the list.

The whole queue is read at once and then trimmed to the requested window: from skips that many requests from the head, count limits how many are returned, and the default of both returns everything. The queue is live, so a repeated call may see a different set. The queue must be opened with DealerStart first.

Timeout: 30 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
from query integer (int32) no Number of requests to skip from the head of the queue; 0 by default.
count query integer (int32) no Maximum number of requests to return; 0 returns the whole queue.
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 30 s (history or report). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Responses

Example

curl "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/RequestGetAll" \
  -H "Authorization: Bearer $TOKEN"

Bring orders, positions and balance of an account in line with an external system

POST /api/v2/MT5/{tradePlatform}/TradeAccountSet

Makes the orders, positions and balance of the account match the passed state. The trade server compares the lists with its own data and performs the difference as deals with the sync reason: positions missing on one side are opened or closed, positions whose direction, price or contract size changed are reopened, a volume change is corrected, and a balance difference becomes a balance or correction deal. All of it stays in the trading history of the client.

The operation is heavy and changes money and positions: it must be used by the system that owns the account, not as a general-purpose edit. An omitted order or position list leaves that part untouched; an empty list states that the account has none and closes the existing ones. The call answers as soon as the trade server has accepted it, and the resulting state of the account is reported to the platform journal.

Timeout: 5 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: The operation may still be completed by the server (X-Request-Outcome: unknown): check its result before repeating it.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 5 s (trade operation). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Request body

TradeAccountSetRequest (application/json) — Account state to apply.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/TradeAccountSet" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "requestId": 0, "login": 0, "balance": 0, "orders": [{}], "positions": [{}] }'

Calculate the profit of a position

POST /api/v2/MT5/{tradePlatform}/TradeProfit

Calculates the profit a position with the given direction, volume and prices would bring, in the deposit currency of the group, together with the rate that converts the profit currency of the symbol into that currency. The calculation uses the current market prices of the group, so the symbol must be available to that group.

Nothing is created or changed: the result describes a hypothetical position only. The volume uses four decimal places of a lot; for the extended accuracy use the variant with the Ext suffix.

Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 10 s (read). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Request body

TradeProfitRequest (application/json) — Conditions of the calculation.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/TradeProfit" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "group": "", "symbol": "", "type": "Buy", "volume": 0, "priceOpen": 0, "priceClose": 0 }'

Calculate the profit of a position with extended volume accuracy

POST /api/v2/MT5/{tradePlatform}/TradeProfitExt

The same calculation as TradeProfit, with the volume given in eight decimal places of a lot instead of four. Nothing is created or changed.

Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 10 s (read). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Request body

TradeProfitRequest (application/json) — Conditions of the calculation.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/TradeProfitExt" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "group": "", "symbol": "", "type": "Buy", "volume": 0, "priceOpen": 0, "priceClose": 0 }'

Check whether an account has the margin an order requires

POST /api/v2/MT5/{tradePlatform}/TradeMarginCheck

Checks whether the given account can place the described order, and returns the state of the account before and after it. The margin of the hypothetical order is estimated from the current state of the account and the current prices of its group, so the after state is approximate.

Nothing is created or changed. An account without enough free margin is a normal answer (allowed is false) and not an error. The volume uses four decimal places of a lot; for the extended accuracy use the variant with the Ext suffix.

Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 10 s (read). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Request body

TradeMarginCheckRequest (application/json) — Order whose margin requirement is checked.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/TradeMarginCheck" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "login": 0, "symbol": "", "type": "Buy", "volume": 0, "price": 0 }'

Check the margin of an order with extended volume accuracy

POST /api/v2/MT5/{tradePlatform}/TradeMarginCheckExt

The same check as TradeMarginCheck, with the volume given in eight decimal places of a lot instead of four. Nothing is created or changed; an account without enough free margin is a normal answer and not an error.

Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 10 s (read). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Request body

TradeMarginCheckRequest (application/json) — Order whose margin requirement is checked.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/TradeMarginCheckExt" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "login": 0, "symbol": "", "type": "Buy", "volume": 0, "price": 0 }'

Calculate the rate of buying a currency for another one

POST /api/v2/MT5/{tradePlatform}/TradeRateBuy

Calculates how much of the calculation currency pays for one unit of the base currency when it is bought. With a group the spread adjustment of that group is applied; without it the market prices are used. A symbol and its price replace the market quote of that symbol in the calculation, unless the symbol is always converted at the market price.

Nothing is created or changed. The rate is built from current market data, so the connection must have the orders and positions of the platform loaded.

Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 10 s (read). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Request body

TradeRateRequest (application/json) — Conditions of the calculation.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/TradeRateBuy" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "base": "", "currency": "", "group": "", "symbol": "", "price": 0 }'

Calculate the rate of selling a currency for another one

POST /api/v2/MT5/{tradePlatform}/TradeRateSell

The same calculation as TradeRateBuy for a sale: how much of the calculation currency is received for one unit of the base currency. Nothing is created or changed.

Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 10 s (read). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Request body

TradeRateRequest (application/json) — Conditions of the calculation.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/TradeRateSell" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "base": "", "currency": "", "group": "", "symbol": "", "price": 0 }'

Schemas

Types the operations above take and return, with their first-level properties; * marks a required one. The full graph is in the OpenAPI specification.

BooleanApiResponse

Unified v2 response envelope: data is the payload (null on error); error is the error object (null on success, always serialised); meta contains response metadata (activityId and optional paging). HTTP status is always 200.

PropertyTypeDescription
data boolean
error ApiError v2 error body. Code is the stable transport error code; ManagerCode is the raw MT4 ResultCode (serialized as a string for a known enum member, or as a number for an unrecognised value returned by MT4); Message is a human-readable description.
meta ApiMeta Response metadata. ActivityId identifies the request — quote it when you contact support. Paging is present only on paginated list responses; otherwise it is omitted.

MT5RequestApiResponse

Unified v2 response envelope: data is the payload (null on error); error is the error object (null on success, always serialised); meta contains response metadata (activityId and optional paging). HTTP status is always 200.

PropertyTypeDescription
data MT5Request
error ApiError v2 error body. Code is the stable transport error code; ManagerCode is the raw MT4 ResultCode (serialized as a string for a known enum member, or as a number for an unrecognised value returned by MT4); Message is a human-readable description.
meta ApiMeta Response metadata. ActivityId identifies the request — quote it when you contact support. Paging is present only on paginated list responses; otherwise it is omitted.

MT5Confirm

PropertyTypeDescription
id integer (int32), nullable request id
retCode MT5Result confirmation retcode
volume integer (int64), nullable confirmed volume
price number (double), nullable confirmed price
tickBid number (double), nullable confirmed tick bid
tickAsk number (double), nullable confirmed tick ask
tickLast number (double), nullable confirmed tick last
comment string, nullable confirmation comment
flags integer (int32), nullable flags
dealID string, nullable linked deal id in external system
orderID string, nullable linked order id in external system
priceGateway number (double), nullable execution price on gateway
positionExternalID string, nullable linked position ticket in external system
externalRetCode integer (int32), nullable external trade system return code
volumeExt integer (int64), nullable

MT5RequestListApiResponse

Unified v2 response envelope: data is the payload (null on error); error is the error object (null on success, always serialised); meta contains response metadata (activityId and optional paging). HTTP status is always 200.

PropertyTypeDescription
data MT5Request[]
error ApiError v2 error body. Code is the stable transport error code; ManagerCode is the raw MT4 ResultCode (serialized as a string for a known enum member, or as a number for an unrecognised value returned by MT4); Message is a human-readable description.
meta ApiMeta Response metadata. ActivityId identifies the request — quote it when you contact support. Paging is present only on paginated list responses; otherwise it is omitted.

TradeAccountSetRequest

State of an account taken from an external trading system, v2 request DTO.

PropertyTypeDescription
requestId integer (int64), nullable Caller-side identifier used to tie the call to its completion event; optional.
login integer (int64) Login of the account whose data is synchronised.
balance number (double), nullable Balance the account must have after the synchronisation.
orders MT5Order[] Orders the account must have; omitted means the orders are not synchronised.
positions MT5Position[] Positions the account must have; omitted means the positions are not synchronised.

TradeProfitRequest

Conditions of a profit calculation, v2 request DTO.

PropertyTypeDescription
group string, nullable Group whose deposit currency and prices are used for the calculation.
symbol string, nullable Symbol the calculation is performed for.
type OrderType Direction of the hypothetical position; only buy and sell are meaningful here.
volume integer (int64) Position volume; one unit is 1/10000 lot in the standard variant and 1/100000000 in the extended one.
priceOpen number (double) Open price of the hypothetical position.
priceClose number (double) Close price of the hypothetical position.

TradeProfitResultApiResponse

Unified v2 response envelope: data is the payload (null on error); error is the error object (null on success, always serialised); meta contains response metadata (activityId and optional paging). HTTP status is always 200.

PropertyTypeDescription
data TradeProfitResult Result of a profit calculation, v2 response DTO.
error ApiError v2 error body. Code is the stable transport error code; ManagerCode is the raw MT4 ResultCode (serialized as a string for a known enum member, or as a number for an unrecognised value returned by MT4); Message is a human-readable description.
meta ApiMeta Response metadata. ActivityId identifies the request — quote it when you contact support. Paging is present only on paginated list responses; otherwise it is omitted.

TradeMarginCheckRequest

Order whose margin requirement is checked, v2 request DTO.

PropertyTypeDescription
login integer (int64) Login of the account the hypothetical order would be placed on.
symbol string, nullable Symbol of the hypothetical order.
type OrderType Type of the hypothetical order.
volume integer (int64) Order volume; one unit is 1/10000 lot in the standard variant and 1/100000000 in the extended one.
price number (double) Execution price of the hypothetical order.

TradeMarginCheckResultApiResponse

Unified v2 response envelope: data is the payload (null on error); error is the error object (null on success, always serialised); meta contains response metadata (activityId and optional paging). HTTP status is always 200.

PropertyTypeDescription
data TradeMarginCheckResult Answer of a margin check, v2 response DTO.
error ApiError v2 error body. Code is the stable transport error code; ManagerCode is the raw MT4 ResultCode (serialized as a string for a known enum member, or as a number for an unrecognised value returned by MT4); Message is a human-readable description.
meta ApiMeta Response metadata. ActivityId identifies the request — quote it when you contact support. Paging is present only on paginated list responses; otherwise it is omitted.

TradeRateRequest

Conditions of a conversion rate calculation, v2 request DTO.

PropertyTypeDescription
base string, nullable Currency bought or sold, a three-letter code such as EUR.
currency string, nullable Currency the base currency is paid with, a three-letter code such as USD.
group string, nullable Group whose spread adjustment is applied; omitted means market prices.
symbol string, nullable Symbol to use in place of the market one.
price number (double), nullable Price of the symbol above; ignored for the symbols always converted at the market price.

TradeRateResultApiResponse

Unified v2 response envelope: data is the payload (null on error); error is the error object (null on success, always serialised); meta contains response metadata (activityId and optional paging). HTTP status is always 200.

PropertyTypeDescription
data TradeRateResult Result of a conversion rate calculation, v2 response DTO.
error ApiError v2 error body. Code is the stable transport error code; ManagerCode is the raw MT4 ResultCode (serialized as a string for a known enum member, or as a number for an unrecognised value returned by MT4); Message is a human-readable description.
meta ApiMeta Response metadata. ActivityId identifies the request — quote it when you contact support. Paging is present only on paginated list responses; otherwise it is omitted.

ApiError

v2 error body. Code is the stable transport error code; ManagerCode is the raw MT4 ResultCode (serialized as a string for a known enum member, or as a number for an unrecognised value returned by MT4); Message is a human-readable description.

PropertyTypeDescription
code WebApiErrorCode Stable transport-level error code.
managerCode ResultCode Raw MT4/MT5 manager result code, when the error came from the trading platform; otherwise null.
message string, nullable Human-readable error description.

ApiMeta

Response metadata. ActivityId identifies the request — quote it when you contact support. Paging is present only on paginated list responses; otherwise it is omitted.

PropertyTypeDescription
activityId string, nullable W3C trace id of the request. Quote it when you contact support: it finds this exact call in the server logs.
paging PagingMeta Pagination info; present only on list responses, omitted otherwise.

MT5Request

PropertyTypeDescription
id integer (int32), nullable Read-only: the trade server does not let this value be changed. request id
login * integer (int64) client login
group string, nullable Read-only: the trade server does not let this value be changed.
symbol * string symbol
digits integer (int32), nullable price digits
action * TradeActions TradeActions
timeExpiration string (date-time), nullable order expiration
type * OrderType order type IMTOrder::OrderType
typeFill OrderFilling IMTOrder::OrderFilling
typeTime OrderTime IMTOrder::OrderTime
flags TradeActionFlags additional flags TradeActionFlags
volume * integer (int64) 1 lot = 10_000
order integer (int64), nullable order ticket
orderExternalID string, nullable order ticket in external system (exchange, ECN, etc)
priceOrder * number (double) order price
priceTrigger number (double), nullable order trigger price
priceSL number (double), nullable order SL price
priceTP number (double), nullable order TP price
priceDeviation integer (int64), nullable price deviation details
priceDeviationTop number (double), nullable
priceDeviationBottom number (double), nullable
comment string, nullable comment
resultRetCode MT5Result Read-only: the trade server does not let this value be changed. request result information
resultDealer integer (int64), nullable request result deal request dealer
resultDeal integer (int64), nullable Read-only: the trade server does not let this value be changed. request result deal
resultOrder integer (int64), nullable Read-only: the trade server does not let this value be changed. request result order
resultVolume integer (int64), nullable Read-only: the trade server does not let this value be changed. request result confirmed volume
resultPrice number (double), nullable Read-only: the trade server does not let this value be changed. request result confirmed price
resultDealerBid number (double), nullable Read-only: the trade server does not let this value be changed. request result dealer prices
resultDealerAsk number (double), nullable Read-only: the trade server does not let this value be changed.
resultDealerLast number (double), nullable Read-only: the trade server does not let this value be changed.
resultMarketBid number (double), nullable Read-only: the trade server does not let this value be changed. request result market prices
resultMarketAsk number (double), nullable Read-only: the trade server does not let this value be changed.
resultMarketLast number (double), nullable Read-only: the trade server does not let this value be changed.
resultComment string, nullable Read-only: the trade server does not let this value be changed. request result comment
externalAccount string, nullable external system trade account (exchange, ECN, etc)
idClient integer (int32), nullable Read-only: the trade server does not let this value be changed. client side request id
ip string, nullable source request ip
sourceLogin integer (int64), nullable source dealer login (for dealer transaction)
position integer (int64), nullable position ticket
positionBy integer (int64), nullable position ticket for close-by
positionExternalID string, nullable position ticket in external system (exchange, ECN, etc)
positionByExternalID string, nullable position ticket in external system (exchange, ECN, etc)
volumeExt integer (int64), nullable volume with extended accuracy, 1 lot = 100_000_000
resultVolumeExt integer (int64), nullable Read-only: the trade server does not let this value be changed. request result confirmed volume with extended accuracy
volumeCurrent integer (int64), nullable current order volume
volumeCurrentExt integer (int64), nullable current order volume

MT5Result

Values: Ok, OkNone, Error, ErrParams, ErrData, ErrDisk, ErrMem, ErrNetwork, ErrPermissions, ErrTimeout, ErrConnection, ErrNoService, ErrFrequent, ErrNotfound, ErrPartial, ErrShutdown, ErrCancel, ErrDuplicate, AuthClientInvalid, AuthAccountInvalid, AuthAccountDisabled, AuthAdvanced, AuthCertificate, AuthCertificateBad, AuthNotConfirmed, AuthServerInternal, AuthServerBad, AuthUpdateOnly, AuthClientOld, AuthManagerNoConfig, AuthManagerIPBlock, AuthGroupInvalid, AuthCaDisabled, AuthInvalidID, AuthInvalidIp, AuthInvalidType, AuthServerBusy, AuthServerCert, AuthAccountUnknown, AuthServerOld, AuthServerLimit, AuthMobileDisabled, AuthManagerType, AuthDemoDisabled, AuthResetPassword, AuthOTPInvalid, AuthOTPNeedSecret, AuthMigrationMT4, AuthMigrationMT5, AuthInvalidVerify, AuthVerifyBadEmail, AuthVerifyBadPhone, AuthAPIDisabled, CfgLastAdmin, CfgLastAdminGroup, CfgNotEmpty, CfgInvalidRange, CfgNotManagerLogin, CfgBuiltin, CfgDuplicate, CfgLimitReached, CfgNoAccessToMain, CfgDealerIDExist, CfgBindAddressExist, CfgWorkingTrade, CfgGatewayNameExist, CfgSwitchToBackup, CfgNoBackupModule, CfgNoTradeModule, CfgNoHistoryModule, CfgAnotherSwitch, CfgNoLicenseFile, CfgGatewayLoginExist, CfgInvalidCompany, UsrLastAdmin, UsrLoginExhausted, UsrLoginProhibited, UsrLoginExist, UsrSuicide, UsrInvalidPassword, UsrLimitReached, UsrHasTrades, UsrDifferentServers, UsrDifferentCurrency, UsrImportBalance, UsrImportGroup, UsrAccountExist, UsrImportAccount, UsrImportPositions, UsrImportOrders, UsrImportDeals, UsrImportHistory, UsrAPILimitReached, TradeLimitReached, TradeOrderExist, TradeOrderExhausted, TradeDealExhausted, TradeMaxMoney, TradeDealExist, TradeOrderProhibited, TradeDealProhibited, TradeSplitVolume, ReportSnapshot, ReportNotSupported, ReportNodata, ReportTemplateBad, ReportTemplateEnd, ReportInvalidRow, ReportLimitRepeat, ReportLimitReport, HstSymbolNotfound, RequestInWay, RequestAccepted, RequestProcess, RequestRequote, RequestPrices, RequestReject, RequestCancel, RequestPlaced, RequestDone, RequestDonePartial, RequestError, RequestTimeout, RequestInvalid, RequestInvalidVolume, RequestInvalidPrice, RequestInvalidStops, RequestTradeDisabled, RequestMarketClosed, RequestNoMoney, RequestPriceChanged, RequestPriceOff, RequestInvalidExp, RequestOrderChanged, RequestTooMany, RequestNoChanges, RequestAtDisabledServer, RequestAtDisabledClient, RequestLocked, RequestFrozen, RequestInvalidFill, RequestConnection, RequestOnlyReal, RequestLimitOrders, RequestLimitVolume, RequestInvalidOrder, RequestPositionClosed, RequestExecutionSkipped, RequestInvalidCloseVolume, RequestCloseOrderExist, RequestLimitPositions, RequestRejectCancel, RequestLongOnly, RequestShortOnly, RequestCloseOnly, RequestProhibitedByFifo, RequestHedgeProhibited, RequestReturn, RequestDoneCancel, RequestRequoteReturn, ErrNotImplement, ErrNotMain, ErrNotSupported, ErrDeadlock, ErrLocked, MessengerInvalidPhone, MessengerNotMobile, SubsNotFound, SubsNotFoundCfg, SubsNotFoundUser, SubsDisabled, SubsPermissionUser, SubsPermissionSubscribe, SubsPermissionUnsubscribe, SubsRealOnly, SubsPaymentMethod, PayRealOnly, PayInvalidAmount, PayNotAllowedDeposit, PayNotAllowedWithdrawal, PayNotAllowedGroup, PayNotAllowedCountry, PayDeclineByRules, PayDeclineByAml, PayLimitDepositMin, PayLimitDepositMax, PayLimitWithdrawalMin, PayLimitWithdrawalMax, PayProviderPayment, PayProviderStatus, PayConversion, PayNotWaiting, PayVerification, PayInvoice, PayInvalidCurrency, PayLimitReached, PayProviderRefund, PayDeclineByCardholderName

MT5Order

PropertyTypeDescription
order integer (int64), nullable order ticket
externalID string, nullable order ticket in external system (exchange, ECN, etc)
login integer (int64), nullable client login
dealer integer (int64), nullable processed dealer login (0-means auto)
partyID integer (int64), nullable counterparty identification
symbol string, nullable order symbol
digits integer (int32), nullable price digits
digitsCurrency integer (int32), nullable currency digits
contractSize number (double), nullable contract size
state OrderState OrderState
reason OrderReason OrderReason
timeSetup string (date-time), nullable order setup time
timeExpiration string (date-time), nullable order expiration
timeDone string (date-time), nullable order filling/cancel time
type OrderType OrderType
typeFill OrderFilling OrderFilling
typeTime OrderTime OrderTime
priceOrder number (double), nullable order price
priceTrigger number (double), nullable order trigger price (stop-limit price)
priceCurrent number (double), nullable order current price
priceSL number (double), nullable order SL
priceTP number (double), nullable order TP
volumeInitial integer (int64), nullable order initial volume
volumeCurrent integer (int64), nullable order current volume
expertID integer (int64), nullable expert id (filled by expert advisor)
positionID integer (int64), nullable position id
comment string, nullable order comment
activationMode integer (int32), nullable Read-only: the trade server does not let this value be changed. order activation state, time and price
activationTime string (date-time), nullable Read-only: the trade server does not let this value be changed.
activationPrice number (double), nullable Read-only: the trade server does not let this value be changed. Gets the price, at which the order was activated
activationFlags TradeActivationFlags Read-only: the trade server does not let this value be changed.
timeSetupMsc string (date-time), nullable Gets and sets the order placing time in milliseconds, since 1970.01.01 If the value of this field is specified, the TimeSetup value will be filled in automatically.
timeDoneMsc string (date-time), nullable Gets and sets the order execution time in milliseconds, since 1970.01.01 If the value of this field is specified, the TimeDone value will be filled in automatically.
rateMargin number (double), nullable margin conversion rate (from symbol margin currency to deposit currency)
positionByID integer (int64), nullable position by id
modificationFlags integer (int32), nullable modification flags
volumeInitialExt integer (int64), nullable order initial volume with extended accuracy
volumeCurrentExt integer (int64), nullable order current volume with extended accuracy

MT5Position

PropertyTypeDescription
login integer (int64), nullable Gets the login of the client, to whom the trade position belongs
symbol string, nullable position symbol
action PositionActions PositionAction
digits integer (int32), nullable price digits
digitsCurrency integer (int32), nullable currency digits
contractSize number (double), nullable symbol contract size
position integer (int64), nullable position ticket
externalId string, nullable The ticket of a position in an external trading system
timeCreate string (date-time), nullable position create time
timeUpdate string (date-time), nullable position last update time
timeCreateMsc string (date-time), nullable position create time in msc since 1970.01.01 If the value of this field is specified, the TimeCreate value will be filled in automatically.
timeUpdateMsc string (date-time), nullable position last update time in msc since 1970.01.01 If the value of this field is specified, the TimeUpdate value will be filled in automatically.
priceOpen number (double), nullable position weighted average open price
priceCurrent number (double), nullable position current price
priceSL number (double), nullable position SL price
priceTP number (double), nullable position TP price
volume integer (int64), nullable position volume
volumeExt integer (int64), nullable position volume
profit number (double), nullable position floating profit
storage number (double), nullable position accumulated swaps
rateProfit number (double), nullable profit conversion rate (from symbol profit currency to deposit currency)
rateMargin number (double), nullable margin conversion rate (from symbol margin currency to deposit currency)
expertId integer (int64), nullable expert id (filled by expert advisor)
expertPositionId integer (int64), nullable expert position id
comment string, nullable
dealer integer (int64), nullable The login of a dealer, who has processed the order that opened the position. 0 means that the order was processed automatically by the server
activationMode ActivationModes order activation state, time and price
activationTime string (date-time), nullable
activationPrice number (double), nullable
activationFlags TradeActivationFlags
modificationFlags TradeModifyFlags modification flags
reason PositionReasons position reason - PositionReason

OrderType

Values: Buy, Sell, BuyLimit, SellLimit, BuyStop, SellStop, BuyStopLimit, SellStopLimit, CloseBy

TradeProfitResult

Result of a profit calculation, v2 response DTO.

PropertyTypeDescription
profit number (double) Profit of the hypothetical position in the deposit currency of the group.
profitRate number (double) Rate that converts the profit of the symbol into the deposit currency of the group.

TradeMarginCheckResult

Answer of a margin check, v2 response DTO.

PropertyTypeDescription
allowed boolean Whether the account has enough free margin for the order. false is a normal answer, not an error: the order would be rejected by the trade server.
accountNew MT5Account Estimated state of the account after the order; empty when the server did not fill it.
accountCurrent MT5Account State of the account at the moment of the check.

TradeRateResult

Result of a conversion rate calculation, v2 response DTO.

PropertyTypeDescription
rate number (double) Rate of buying or selling the base currency for the calculation currency.