CPlugin

MT4 v2 :: History

API v2 (beta) · MT4 · 1 operation · 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 account trade history

GET /api/v2/MT4/{tradePlatform}/TradesUserHistory/{login}

Closed trades history for a single account in a time range.

Manager (live) call — round-trips to MT4 server. Default time range is "everything" (epoch → MaxValue) when query params are omitted. Returns an empty list if the account has no closed trades in the window. Trades are mapped to the curated MT4Trade DTO; same shape as live TradesGetByMarket / TradesGetBySymbol.

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)
login path integer (int32) yes Account login (positive integer)
fromTime query string (date-time) no Window start (UTC, ISO 8601). Optional.
toTime query string (date-time) no Window end (UTC, ISO 8601). Optional.
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/TradesUserHistory/$LOGIN" \
  -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.

MT4TradeListApiResponse

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

MT4Trade

v2 DTO mirroring the wrapper's TradeRecord. The set of fields is curated for typical client use-cases — order monitoring, P&L reporting, trade history reconciliation. Internal padding/reserved/gateway-internal/raw underscore-prefixed fields are intentionally excluded. Span<>-typed helpers (ConvRates, ConvReserv, APIData) are excluded because System.Text.Json cannot serialize ref-struct-backed properties — those would force callers onto a custom converter for marginal value. Enum members (TradeCommand, TradeRecordState, TradeRecordReason, ActivationType) serialize as string names via V2JsonContext UseStringEnumConverter — e.g. "Buy" rather than 0.

PropertyTypeDescription
order integer (int32) Order ticket number
login integer (int32) Owner account login
symbol string, nullable Symbol traded (e.g. EURUSD)
digits integer (int32) Symbol precision (number of digits after the decimal point)
tradeCommand TradeCommand Trade direction / pending order type (Buy/Sell/BuyLimit/etc)
volume integer (int32) Volume stored ×100 (e.g. 15 means 0.15 lots — see VolumeLots)
volumeLots number (double) Volume expressed in lots, for human consumption (Volume / 100)
tradeRecordState TradeRecordState Lifecycle state of the trade record
openPrice number (double) Price at which the order was opened
sl number (double) Stop-loss price (0 if unset)
tp number (double) Take-profit price (0 if unset)
openTime string (date-time) Order open timestamp
closeTime string (date-time) Order close timestamp (default for still-open orders)
closePrice number (double) Price at which the order was closed
commission number (double) Broker commission
commissionAgent number (double) Agent (IB) commission
storage number (double) Accumulated swap / rollover charges
profit number (double) Realised / floating profit
taxes number (double) Taxes withheld
magic integer (int32) Expert advisor magic number — client-supplied tag
comment string, nullable Free-form order comment
expiration string (date-time) Expiration timestamp for pending orders
tradeRecordReason TradeRecordReason Reason the trade record was created/modified (Client/Expert/Dealer/Stopout/etc)
activationType ActivationType How a pending order was activated
timeStamp string (date-time) Last modification timestamp of the trade record
marginRate number (double) Margin conversion rate (margin currency → deposit currency)

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.