CPlugin

MT4 v2 :: History

API v2 (current) · 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 (scope webapi). The token server belongs to the environment: for the Sandbox call https://pre.mywebapi.com and take the token from https://pre.auth.cplugin.net/connect/token; for Production take it from https://auth.cplugin.net/connect/token. Clients and tokens of the two are separate — a token from one answers 401 on the other. $TRADE_PLATFORM_ID is the id of a trade platform registered in Toolbox. A failed operation is also answered with HTTP 200: check error before using data. Access and transport failures use HTTP codes — see Errors.

Operations

Get account trade history

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

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

Round-trips to the trade 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 record; 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). A call that reaches an operation answers HTTP 200 — only transport failures (401, 403, 404, 400, 5xx) use other status codes.

PropertyTypeDescription
data MT4Trade[]
error ApiError v2 error body, present when a call failed even though it answered HTTP 200. Code is the stable error category. ManagerCode is the raw result code of the trade server on MT4 (null otherwise: on MT5 the result name is in Message). 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.

MT4Trade

v2 record mirroring the platform'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, as are the raw conversion-rate and API data blocks (ConvRates, ConvReserv, APIData). Enum members (TradeCommand, TradeRecordState, TradeRecordReason, ActivationType) are returned as their names — 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, present when a call failed even though it answered HTTP 200. Code is the stable error category. ManagerCode is the raw result code of the trade server on MT4 (null otherwise: on MT5 the result name is in Message). Message is a human-readable description.

PropertyTypeDescription
code WebApiErrorCode Stable transport-level error code.
managerCode ResultCode Raw MT4 result code when ApiError.Code is MT4Error; null otherwise. On MT5 the result name is in ApiError.Message.
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.