CPlugin

MT4 v2 :: Dealer

API v2 (current) · MT4 · 10 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

Get the summary of one symbol

GET /api/v2/MT4/{tradePlatform}/SummaryGet/{symbol}

Position of all client and coverage orders in one symbol: order counts, buy and sell volumes, average prices and the profit carried at the moment of the call.

The figures are calculated by the trade server over the orders it holds now, not over the trade history. A symbol with no open orders answers with zero volumes. A symbol that does not exist on the server answers with the platform's not-found code in the error envelope.

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 id (GUID)
symbol path string yes Symbol name (e.g. EURUSD)
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.

Responses

Example

curl "https://cloud.mywebapi.com/api/v2/MT4/$TRADE_PLATFORM_ID/SummaryGet/$SYMBOL" \
  -H "Authorization: Bearer $TOKEN"

Get the summary of every symbol

GET /api/v2/MT4/{tradePlatform}/SummaryGetAll

One summary record per symbol the trade server holds — the same shape as the single-symbol read, for the whole symbol list at once.

The figures are a live calculation over the orders open at the moment of the call, so two calls in a row usually differ. Symbols with no open orders are included with zero volumes.

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 id (GUID)
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/MT4/$TRADE_PLATFORM_ID/SummaryGetAll" \
  -H "Authorization: Bearer $TOKEN"

Get the summary of a symbol by its position in the symbol list

GET /api/v2/MT4/{tradePlatform}/SummaryGetByCount/{count}

The same summary record as the single-symbol read, addressed by the symbol's position in the server's symbol list instead of by name — useful for walking the whole list without naming every symbol.

A position outside the list answers with the platform's invalid-data code in the error envelope. Positions are not stable across a symbol list change (a symbol added or removed shifts the ones after it).

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 id (GUID)
count path integer (int32) yes Zero-based position of the symbol in the server's symbol list
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.

Responses

Example

curl "https://cloud.mywebapi.com/api/v2/MT4/$TRADE_PLATFORM_ID/SummaryGetByCount/$COUNT" \
  -H "Authorization: Bearer $TOKEN"

Get the summary of a symbol by its group

GET /api/v2/MT4/{tradePlatform}/SummaryGetByType/{secType}

The same summary record as the single-symbol read, addressed by the index of the symbol group the symbol belongs to. When the group holds more than one symbol, the record describes the first of them; use the single-symbol or position read for a specific one.

A group index that does not exist answers with the platform's invalid-data code in the error envelope.

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 id (GUID)
secType path integer (int32) yes Symbol group index
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.

Responses

Example

curl "https://cloud.mywebapi.com/api/v2/MT4/$TRADE_PLATFORM_ID/SummaryGetByType/$SEC_TYPE" \
  -H "Authorization: Bearer $TOKEN"

Get the summary currency

GET /api/v2/MT4/{tradePlatform}/SummaryCurrency

Currency the trade server reports its summary in — the deposit currency of the server, which is also the currency the summary profit is expressed in.

The value is a short code (three letters in practice). A server that has none configured answers with an empty string.

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 id (GUID)
maxChars query integer (int32) no Buffer size for the currency code, in characters (4–256, default 64)
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.

Responses

Example

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

Get the exposure of every currency

GET /api/v2/MT4/{tradePlatform}/ExposureGet

Net broker exposure per currency: the client volume the broker holds and the coverage volume it carries, both in the currency of the record.

Calculated over the orders open at the moment of the call. Only currencies with outstanding orders appear in the answer; an empty list means the broker holds no open position at all.

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 id (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.

Responses

Example

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

Get the exposure of one currency

GET /api/v2/MT4/{tradePlatform}/ExposureValueGet/{currency}

The broker exposure record of a single currency — the same figures the full list carries, for a currency named in the request.

A currency with no outstanding exposure answers with the platform's not-found code in the error envelope rather than a zeroed record.

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 id (GUID)
currency path string yes Currency code to report (e.g. USD)
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.

Responses

Example

curl "https://cloud.mywebapi.com/api/v2/MT4/$TRADE_PLATFORM_ID/ExposureValueGet/$CURRENCY" \
  -H "Authorization: Bearer $TOKEN"

Recalculate the profit of a trade

POST /api/v2/MT4/{tradePlatform}/TradeCalcProfit

Calculates the profit the supplied trade would carry at the prices given in the body, using the symbol's current conversion rates.

Nothing is written anywhere: this is a calculation over a trade that exists only in the request, and it is safe to repeat. The result is the profit in the server's summary currency. An unknown symbol or an unknown direction answers with a validation or platform error in the error envelope.

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 id (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

MT4TradeCalcProfitRequest (application/json) — Trade fields to price

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT4/$TRADE_PLATFORM_ID/TradeCalcProfit" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "login": 0, "symbol": "", "tradeCommand": "", "volume": 0, "openPrice": 0, "closePrice": 0 }'

Write a record to the Manager API log

POST /api/v2/MT4/{tradePlatform}/LogsOut

Files one entry in the trade server's Manager API log under the connection that serves this request: the result code, the source and the message supplied in the body.

The call has no return value of its own — the platform reports success by returning at all — so the answer is a bare true once the entry is filed. Logging must be enabled on the connection (see LogsMode) for the entry to be kept.

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 id (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

MT4LogsOutRequest (application/json) — Entry to file

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT4/$TRADE_PLATFORM_ID/LogsOut" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "code": "", "source": "", "message": "" }'

Set the logging mode of the Manager API connection

POST /api/v2/MT4/{tradePlatform}/LogsMode

Switches the Manager API log of the connection that serves this request on or off.

The setting belongs to the connection, not to the trade server: it affects only the traffic of the connection pool that answered this call, it is not persisted, and it returns to the enabled default when that connection is re-established. Other connections of the same trade platform, and other trade platforms, are not affected.

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 id (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

MT4LogsModeRequest (application/json) — Mode to apply

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT4/$TRADE_PLATFORM_ID/LogsMode" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "mode": "" }'

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.

MT4SymbolSummaryApiResponse

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 MT4SymbolSummary Aggregated position of all client and coverage orders in one symbol — the platform's SymbolSummary record. The values are calculated by the trade server over the orders it holds at the moment of the call, not over the trade history: a summary of a symbol with no open orders carries zero volumes and zero profit.
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.

MT4SymbolSummaryListApiResponse

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 MT4SymbolSummary[]
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.

StringApiResponse

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 string, nullable
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.

MT4ExposureValueListApiResponse

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 MT4ExposureValue[]
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.

MT4ExposureValueApiResponse

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 MT4ExposureValue Broker exposure in one currency — the platform's ExposureValue record. Both volumes are expressed in the base currency of the pair that produced them, converted to the record's currency.
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.

MT4TradeCalcProfitRequest

Input of the profit calculation: the trade fields the calculation reads. Only these fields take part in the result — stops, magic number, comment and timestamps do not change it. Nothing is written anywhere: the trade record is assembled in memory, priced against the symbol's current conversion rates, and only the resulting profit is returned.

PropertyTypeDescription
login integer (int32) Account login the trade would belong to
symbol string, nullable Symbol of the trade (e.g. EURUSD)
tradeCommand string, nullable Trade direction: Buy or Sell. One of: Buy, Sell, BuyLimit, SellLimit, BuyStop, SellStop, Balance, Credit. Case-insensitive; the numeric value is accepted too. Any other value is refused with error code Validation.
volume integer (int32) Volume in MT4 internal units. 1 lot = 100, so e.g. 250 = 2.5 lots.
openPrice number (double) Open price of the trade
closePrice number (double) Close price of the trade

DoubleApiResponse

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 number (double)
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.

MT4LogsOutRequest

One record written to the trade server's Manager API log. The entry is filed under the connection that serves the request, with the result code and source text supplied by the caller.

PropertyTypeDescription
code string, nullable Result code recorded with the entry, reported by name (e.g. Ok). One of: Ok, OkNone, Error, InvalidData, TechProblem, OldVersion, NoConnect, NotEnoughRights, TooFrequent, Malfunction, GenerateKey, SecuritySession, InvalidCompany, AccountDisabled, BadAccountInfo, PublicKeyMissing, TradeTimeout, TradeBadPrices, TradeBadStops, TradeBadVolume, TradeMarketClosed, TradeDisable, TradeNoMoney, TradePriceChanged, TradeOffquotes, TradeBrokerBusy, TradeRequote, TradeOrderLocked, TradeLongOnly, TradeTooManyReq, TradeAccepted, TradeProcess, TradeUserCancel, TradeModifyDenied, TradeContextBusy, TradeExpirationDenied, TradeTooManyOrders, TradeHedgeProhibited, TradeProhibitedByFIFO, UnhandledException. Case-insensitive; the numeric value is accepted too. Any other value is refused with error code Validation.
source string, nullable Source of the entry — the subsystem or integration the record is attributed to
message string, nullable Text of the entry

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.

MT4LogsModeRequest

Logging mode of the connection that serves the request.

PropertyTypeDescription
mode string, nullable Enabled keeps the Manager API log of this connection, Disabled stops it. The mode applies to the connection, not to the whole trade server, and survives only for the lifetime of that connection. One of: Enabled, Disabled. Case-insensitive; the numeric value is accepted too. Any other value is refused with error code Validation.

MT4SymbolSummary

Aggregated position of all client and coverage orders in one symbol — the platform's SymbolSummary record. The values are calculated by the trade server over the orders it holds at the moment of the call, not over the trade history: a summary of a symbol with no open orders carries zero volumes and zero profit.

PropertyTypeDescription
symbol string, nullable Symbol name (e.g. EURUSD)
count integer (int32) Symbol counter — the position of the symbol in the server's symbol list
digits integer (int32) Symbol precision (number of digits after the decimal point)
type integer (int32) Symbol group index the symbol belongs to
orders integer (int32) Number of client orders in the symbol
buyLots integer (int64) Client buy volume in lots ×100 (e.g. 150 means 1.50 lots)
sellLots integer (int64) Client sell volume in lots ×100
buyPrice number (double) Average client buy price
sellPrice number (double) Average client sell price
profit number (double) Client profit in the account currency at the moment of the call
covOrders integer (int32) Number of coverage (broker-side) orders in the symbol
covBuyLots integer (int64) Coverage buy volume in lots ×100
covSellLots integer (int64) Coverage sell volume in lots ×100
covBuyPrice number (double) Average coverage buy price
covSellPrice number (double) Average coverage sell price
covProfit number (double) Coverage profit at the moment of the call

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.

MT4ExposureValue

Broker exposure in one currency — the platform's ExposureValue record. Both volumes are expressed in the base currency of the pair that produced them, converted to the record's currency.

PropertyTypeDescription
currency string, nullable Currency code the exposure is reported in (e.g. USD)
clients number (double) Net client volume held by the broker in this currency
coverage number (double) Net coverage volume the broker carries in this currency