CPlugin

MT5 v2 :: Trades

API v2 (beta) · MT5 · 3 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

List positions by group

GET /api/v2/MT5/{tradePlatform}/PositionByGroup/{mask}

Returns open positions for all logins in groups matching the mask, ordered by Position ID ascending. Use the cursor for the next page.

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).
mask path string yes Group mask — exact group name or a wildcard like "real\*".
limit query integer (int32) no Maximum number of items to return in one page. Omit to return all items in a single page. Maximum allowed value is 5000.
cursor query string no Opaque continuation token. Pass the value from the previous response's meta.paging.nextCursor to fetch the next page; omit for the first page.
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/MT5/$TRADE_PLATFORM_ID/PositionByGroup/$MASK" \
  -H "Authorization: Bearer $TOKEN"

List orders by group

GET /api/v2/MT5/{tradePlatform}/OrderByGroup/{mask}

Returns active and pending orders for all logins in groups matching the mask, ordered by Order ID ascending. Use the cursor for the next page.

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).
mask path string yes Group mask — exact group name or a wildcard like "real\*".
limit query integer (int32) no Maximum number of items to return in one page. Omit to return all items in a single page. Maximum allowed value is 5000.
cursor query string no Opaque continuation token. Pass the value from the previous response's meta.paging.nextCursor to fetch the next page; omit for the first page.
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/MT5/$TRADE_PLATFORM_ID/OrderByGroup/$MASK" \
  -H "Authorization: Bearer $TOKEN"

List deals by group

GET /api/v2/MT5/{tradePlatform}/DealByGroup/{mask}

Returns deals for all logins in groups matching the mask, ordered by Deal ID ascending. Returns the full history by default. Use the cursor for the next page.

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).
mask path string yes Group mask — exact group name or a wildcard like "real\*".
limit query integer (int32) no Maximum number of items to return in one page. Omit to return all items in a single page. Maximum allowed value is 5000.
cursor query string no Opaque continuation token. Pass the value from the previous response's meta.paging.nextCursor to fetch the next page; omit for the first page.
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/DealByGroup/$MASK" \
  -H "Authorization: Bearer $TOKEN"

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.

MT5PositionListApiResponse

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 MT5Position[]
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 is the W3C trace-id for correlation in Seq/SigNoz. Paging is present only on paginated list responses; otherwise it is omitted — the global JSON context policy serialises null fields, so we override that here with System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull.

MT5OrderListApiResponse

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 MT5Order[]
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 is the W3C trace-id for correlation in Seq/SigNoz. Paging is present only on paginated list responses; otherwise it is omitted — the global JSON context policy serialises null fields, so we override that here with System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull.

MT5DealListApiResponse

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 MT5Deal[]
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 is the W3C trace-id for correlation in Seq/SigNoz. Paging is present only on paginated list responses; otherwise it is omitted — the global JSON context policy serialises null fields, so we override that here with System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull.

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

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 is the W3C trace-id for correlation in Seq/SigNoz. Paging is present only on paginated list responses; otherwise it is omitted — the global JSON context policy serialises null fields, so we override that here with System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull.

PropertyTypeDescription
activityId string, nullable W3C trace id for correlating this response in logs and tracing (Seq/SigNoz).
paging PagingMeta Pagination info; present only on list responses, omitted otherwise.

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 Has No Setter In ManagerAPI, so all you can is to read this value. order activation state, time and price
activationTime string (date-time), nullable Has No Setter In ManagerAPI, so all you can is to read this value.
activationPrice number (double), nullable Has No Setter In ManagerAPI, so all you can is to read this value. Gets the price, at which the order was activated
activationFlags TradeActivationFlags Has No Setter In ManagerAPI, so all you can is to read this value.
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

MT5Deal

PropertyTypeDescription
deal * integer (int64) deal ticket
externalID string, nullable deal 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
order integer (int64), nullable deal order ticket
action DealAction DealAction
entry EntryFlag EntryFlags
digits integer (int32), nullable price digits
digitsCurrency integer (int32), nullable currency digits
contractSize number (double), nullable symbol contract size
time string (date-time), nullable deal creation datetime in seconds. If the value of this field is specified, the IMTDeal::TimeMsc value will be filled in automatically.
symbol string, nullable deal symbol
price number (double), nullable deal price
priceSL number (double), nullable order SL
priceTP number (double), nullable order TP
volume integer (int64), nullable deal volume
volumeExt integer (int64), nullable deal volume with extended accuracy
volumeClosed integer (int64), nullable closed volume
volumeClosedExt integer (int64), nullable closed volume with extended accuracy
profit number (double), nullable deal profit
value number (double), nullable value
storage number (double), nullable deal collected swaps
commission number (double), nullable deal commission
obsoleteValue number (double), nullable obsolete value
fee number (double), nullable fee
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)
positionID integer (int64), nullable position id
comment string, nullable deal comment
profitRaw number (double), nullable deal profit in symbol's profit currency
pricePosition number (double), nullable closed position price
tickValue number (double), nullable tick value
tickSize number (double), nullable tick size
flags integer (int64), nullable flags
timeMsc string (date-time), nullable deal creation datetime in msc since 1970.01.01. If the value of this field is specified, the IMTDeal::Time value will be filled in automatically
reason DealReason DealReason
gateway string, nullable source gateway name
priceGateway number (double), nullable deal price on gateway
marketBid number (double), nullable Has No Setter In ManagerAPI, so all you can is to read this value. Get the market Bid price as at the time of deal execution by the server
marketAsk number (double), nullable Has No Setter In ManagerAPI, so all you can is to read this value. Get the market Ask price as at the time of deal execution by the server
marketLast number (double), nullable Has No Setter In ManagerAPI, so all you can is to read this value. Get the market Last price as at the time of deal execution by the server
modificationFlags TradeModifyFlags Has No Setter In ManagerAPI, so all you can is to read this value. modification flags