CPlugin

MT4 v2 :: Prices

API v2 (beta) · MT4 · 8 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 chart bars

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

OHLC chart bars for a symbol over a date range.

Manager (live) call. Resolves the symbol's ConSymbol first (needed by the wrapper to set scale/digits), then asks for bars of the given period in the date window. mode defaults to RangeInExcludeOutOfRage — bars whose time falls strictly inside the window.

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)
symbol path string yes Symbol name (max 12 chars)
period query ChartPeriod no Bar period enum (M1, M5, M15, M30, H1, H4, D1, W1, MN1)
start query string (date-time) no Window start (UTC)
end query string (date-time) no Window end (UTC)
mode query RequestMode no Bar inclusion mode at the edges; defaults to RangeInExcludeOutOfRage.
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/ChartRequest/$SYMBOL" \
  -H "Authorization: Bearer $TOKEN"

Add chart bars

POST /api/v2/MT4/{tradePlatform}/ChartAdd/{symbol}

Append OHLC bars to a symbol's chart history — POST destructive.

Manager (live) call that appends the provided bars to the symbol's historical chart for the given period. The wrapper looks up the symbol's scale (Multiply/Digits) internally to encode the float OHLC values back into native integer prices.

Idempotency-Key strongly recommended — duplicate writes can corrupt the historical data series.

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 id (GUID)
symbol path string yes Symbol name (max 12 chars)
period query ChartPeriod no Bar period enum (M1, M5, M15, M30, H1, H4, D1, W1, MN1)
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.

Request body

MT4ChartWriteRequest (application/json) — OHLC bars to append. Rates must be non-empty.

Responses

Example

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

Update chart bars

POST /api/v2/MT4/{tradePlatform}/ChartUpdate/{symbol}

Overwrite existing OHLC bars in a symbol's chart history — POST destructive.

Manager (live) call. Replaces bars at the timestamps provided in Rates for the given period. Bars whose timestamps don't match an existing bar are silently ignored by the MT4 server.

Idempotency-Key strongly recommended.

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 id (GUID)
symbol path string yes Symbol name (max 12 chars)
period query ChartPeriod no Bar period enum
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.

Request body

MT4ChartWriteRequest (application/json) — OHLC bars to overwrite (matched by Time).

Responses

Example

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

Delete chart bars

POST /api/v2/MT4/{tradePlatform}/ChartDelete/{symbol}

Delete OHLC bars from a symbol's chart history — POST destructive.

Manager (live) call. Removes bars whose Time matches the entries in Rates for the given period. Only the bar timestamp is consulted server-side; OHLC values can be zero.

Idempotency-Key strongly recommended — silently repeating a delete on already-removed bars is harmless, but accidental double-submit could nudge audit logs with extra "operation requested" entries.

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 id (GUID)
symbol path string yes Symbol name (max 12 chars)
period query ChartPeriod no Bar period enum
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.

Request body

MT4ChartWriteRequest (application/json) — Bars to delete; only Time is significant.

Responses

Example

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

Repair chart history

POST /api/v2/MT4/{tradePlatform}/HistoryCorrect/{symbol}

Recompute and patch internal consistency of a symbol's chart history.

Manager (live) call. The MT4 server walks the symbol's full bar history for every period and fixes inconsistencies (gaps, broken OHLC relationships, mismatched aggregates). Returns the count of bars that the server corrected — zero is a valid result (history was already consistent).

Requires Administrator rights on the manager account. The operation can take many seconds on long histories; pair with Idempotency-Key for retry safety so a TCP retry doesn't kick off a second full sweep.

Timeout: 60 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 id (GUID)
symbol path string yes Symbol name (max 12 chars)
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 60 s (server maintenance). 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/MT4/$TRADE_PLATFORM_ID/HistoryCorrect/$SYMBOL" \
  -H "Authorization: Bearer $TOKEN"

Get historical ticks

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

Historical ticks for a symbol over a date range.

Manager (live) call returning a list of MT4TickRecord DTOs. flags controls whether raw and/or normalised ticks are included (defaults to All). Heavy endpoint — pair with Idempotency-Key for retry safety.

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)
symbol path string yes Symbol name (max 12 chars)
start query string (date-time) no Window start (UTC, ISO 8601)
end query string (date-time) no Window end (UTC, ISO 8601)
flags query TickRequestFlags no Tick request flags. Defaults to All.
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/TicksRequest/$SYMBOL" \
  -H "Authorization: Bearer $TOKEN"

Get last tick (cached)

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

Last known bid/ask tick for a single symbol from the pump cache.

Pump-cached read of the last tick. For sub-second updates prefer the SignalR tick stream over polling. Returns NotFound envelope when the pump cache has no tick for the requested symbol (symbol not in the active subscription set, or the platform has never received a tick since startup).

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", max 12 chars)
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/TickInfoLast/$SYMBOL" \
  -H "Authorization: Bearer $TOKEN"

Get last ticks, all symbols (cached)

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

Last known bid/ask tick for ALL symbols in the pump cache.

Snapshot of every symbol the pump has received quotes for. Empty list when no quotes have been received yet. For sub-second updates use the SignalR tick stream — this endpoint is intended for one-shot snapshots (warm-up, monitoring dashboards, idempotent cache scenarios).

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/TickInfoLast" \
  -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.

MT4ChartBarListApiResponse

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

ChartPeriod

Values: M1, M5, M15, M30, H1, H4, D1, W1, Mn1

RequestMode

Values: RangeIn, RangeOut, RangeLast, RangeInExcludeOutOfRage

MT4ChartWriteRequest

v2 request body for the ChartAdd / ChartUpdate / ChartDelete trio. Wraps the bars list so the request shape stays extensible — future metadata (e.g. SkipIntegrityCheck) can be added without a breaking change to clients that only sent Rates.

PropertyTypeDescription
rates MT4ChartBar[] OHLC bars to add / update / delete. Must be non-empty.

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

Int32ApiResponse

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 integer (int32)
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.

MT4TickRecordListApiResponse

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

TickRequestFlags

Flags: names of the set bits joined by ", " ("Raw, Normal"), "None" when none is set; a set bit without a name is "Bit<n>" (bit number). Bits: Raw = 0x1, Normal = 0x2. Accepted on input, never written: All = Raw, Normal.

MT4TickInfoApiResponse

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 MT4TickInfo v2 DTO describing the last known tick for a trading symbol. Pump-cached snapshot of bid/ask quote — for sub-second updates, prefer the SignalR tick stream over polling this endpoint. The wrapper's TickInfo has no additional fields; the curated DTO is 1:1 on field semantics with the wrapper, only the timestamp source field is renamed for readability (Ctm → Time).
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.

MT4TickInfoListApiResponse

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

MT4ChartBar

v2 DTO for one OHLC chart bar. Curated from the wrapper's RateInfoEx; drops the internal SymbolMultiply/Digits scaling helpers (callers don't need them — the wrapper's buildRI already normalised Open/High/Low/Close from raw int prices into floating point).

PropertyTypeDescription
time string (date-time) Bar timestamp (UTC, start of the bar's period)
open number (float) Open price
high number (float) High price during the bar
low number (float) Low price during the bar
close number (float) Close price
volume number (double) Trading volume during the bar (lots × 100 in MT4 convention)

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.

MT4TickRecord

v2 DTO for one historical tick from TicksRequest. Same fields as the wrapper's TickRecord; Ctm is renamed to Time at the API boundary (consistent with CPlugin.SaaSWebApps.WebAPI.DTOs.MT4.v2.MT4TickInfo). The wrapper's TickRequestFlags enum is exposed as a string to avoid the leaf-enum nested-generic serialization issue documented in feedback-stj-enum-leaf-nested.

PropertyTypeDescription
time string (date-time) Server-side tick timestamp (UTC)
bid number (double) Bid price
ask number (double) Ask price
dataFeed integer (int32) Index of the data feed source
flags string, nullable Tick flags as string — combination of Raw, Normal, All. String-typed for the same STJ source-gen reason as CPlugin.SaaSWebApps.WebAPI.DTOs.MT4.v2.MT4ServerLog.Code.

MT4TickInfo

v2 DTO describing the last known tick for a trading symbol. Pump-cached snapshot of bid/ask quote — for sub-second updates, prefer the SignalR tick stream over polling this endpoint. The wrapper's TickInfo has no additional fields; the curated DTO is 1:1 on field semantics with the wrapper, only the timestamp source field is renamed for readability (Ctm → Time).

PropertyTypeDescription
symbol string, nullable Symbol the tick applies to (e.g. "EURUSD")
time string (date-time) Server-side tick timestamp (UTC)
bid number (double) Bid price (best price at which the broker is buying)
ask number (double) Ask price (best price at which the broker is selling)