How to connect, authenticate and reconnect is on the realtime overview.
The trade platform is fixed by the connection, so no call takes it as an argument. Send every argument of a call:
SignalR does not apply defaults declared on the server, so where a parameter has a default the table names the value to
send, and null stands for "all" or "default" where a parameter accepts it. The first event,
OnMT5ConnectionStatus,
arrives without subscribing.
Calls that start or stop a push of events to this connection.
SubscribeToTicks
SubscribeToTicks(symbol)
Subscribe to tick updates of one symbol
After this call the server pushes OnTick to the calling
connection for every new tick of symbol on the bound trade platform.
Call it once per instrument; several symbols can be subscribed on the same connection.
Subscribe to tick updates of every symbol on the bound trade platform
After this call the server pushes OnTick to the calling
connection for every tick of every instrument on the bound trade platform — the same event
and payload as SubscribeToTicks, without a symbol filter. Repeating the call
replaces the previous all-symbol subscription; per-symbol subscriptions stay in place and an
instrument subscribed both ways is pushed once per subscription. Use
UnsubscribeFromAllTicks to stop it.
Permission: Request (read) on symbols
Example
await connection.invoke("SubscribeToAllTicks");
UnsubscribeFromAllTicks
UnsubscribeFromAllTicks()
Unsubscribe from tick updates of all symbols
Stops the all-symbol OnTick pushes started by
SubscribeToAllTicks. Per-symbol subscriptions stay in place; calling it with
no active all-symbol subscription does nothing.
Subscribe to tick updates of one symbol as batches
The server accumulates the ticks of symbol and sends them as one
OnTicksBatch event once the oldest buffered tick has waited
intervalMs milliseconds, or as soon as maxBatchSize
ticks are buffered. The timer checks about every 50 ms, so a shorter interval behaves as 50 ms.
Each batch is sent to the calling connection only, so it receives no per-tick
OnTick events for the symbol; SubscribeToTicks remains
the lowest-latency option. Subscribing twice to the same symbol replaces the previous
subscription, so a new interval and batch size take effect.
Permission: Request (read) on symbols
Arguments
Name
Type
For the default, send
Description
symbol
string
—
Instrument name as reported by the trade server.
intervalMs
integer
200
Upper bound on how long a tick waits for its batch, in milliseconds; 20 to 60000. Send 200 for the default.
maxBatchSize
integer
200
Upper bound on ticks per event; 1 to 10000. Send 200 for the default. Reaching it sends the batch at once.
Subscribe to account-record updates of the bound trade platform
After this call the server pushes OnUser to the calling
connection for every account added, changed, deleted, archived or restored on the platform.
The payload is slim by design: passwords, OTP secrets and the MQID are never sent over the hub.
Permission: Request (read) on accounts
Example
await connection.invoke("SubscribeToUsers");
UnsubscribeFromUsers
UnsubscribeFromUsers()
Unsubscribe from account-record updates
Stops OnUser pushes for the calling connection.
Subscriptions to other record types stay in place.
Permission: Request (read) on accounts
Example
await connection.invoke("UnsubscribeFromUsers");
SubscribeToDeals
SubscribeToDeals()
Subscribe to deal-record updates of the bound trade platform
After this call the server pushes OnDeal for every deal added,
changed or deleted on the platform, and OnDealClean when all
cached deals of one account are dropped.
Permission: Request (read) on orders and deals
Example
await connection.invoke("SubscribeToDeals");
UnsubscribeFromDeals
UnsubscribeFromDeals()
Unsubscribe from deal-record updates
Stops OnDeal and OnDealClean
pushes for the calling connection. Other subscriptions stay in place.
Permission: Request (read) on orders and deals
Example
await connection.invoke("UnsubscribeFromDeals");
SubscribeToOrders
SubscribeToOrders()
Subscribe to order-record updates of the bound trade platform
After this call the server pushes OnOrder for every order added,
changed or deleted on the platform, OnOrderClean when all cached
orders of one account are dropped, and OnOrderSync once the full
snapshot has been delivered.
Permission: Request (read) on orders and deals
Example
await connection.invoke("SubscribeToOrders");
UnsubscribeFromOrders
UnsubscribeFromOrders()
Unsubscribe from order-record updates
Stops the order-record events of the calling connection. Other subscriptions stay in place.
Permission: Request (read) on orders and deals
Example
await connection.invoke("UnsubscribeFromOrders");
SubscribeToPositions
SubscribeToPositions()
Subscribe to position-record updates of the bound trade platform
After this call the server pushes OnPosition for every position
opened, changed or closed on the platform, OnPositionClean when
all cached positions of one account are dropped, and OnPositionSync
once the full snapshot has been delivered. A closed position arrives as a delete with zeroed
volume and open price.
Permission: Request (read) on orders and deals
Example
await connection.invoke("SubscribeToPositions");
UnsubscribeFromPositions
UnsubscribeFromPositions()
Unsubscribe from position-record updates
Stops the position-record events of the calling connection. Other subscriptions stay in place.
Subscribe to symbol-configuration updates of the bound trade platform
After this call the server pushes OnSymbol for every symbol added,
changed or deleted on the platform and OnSymbolSync once the full
symbol snapshot has been delivered. Only the trading-relevant configuration fields are pushed;
session calendars, tick filters and instant-execution internals stay on the REST surface.
For live prices of one instrument use SubscribeToTicks instead.
Permission: Request (read) on symbols
Example
await connection.invoke("SubscribeToSymbols");
UnsubscribeFromSymbols
UnsubscribeFromSymbols()
Unsubscribe from symbol-configuration updates
Stops the symbol-configuration events of the calling connection. Real-time price
subscriptions are unaffected.
Returns a server-to-client async stream of ticks. With no symbol the stream
carries every instrument of the bound trade platform; with a symbol it carries that symbol only,
matched case-insensitively. The stream stays open until the client cancels it or disconnects.
Returns a server-to-client async stream of margin-call and stop-out events
for all accounts on the connected trade platform. Each item carries the account
login, event type, and update direction.
Whether WebAPI is connected to the trade platform behind the hub. Sent once right after the
client connects (with the current state) and again at every change; needs no subscribing call.
connection.on("OnMT5ConnectionStatus", data => console.log(data));
New tick of a subscribed symbol. Emitted for subscriptions made with
SubscribeToTicks and, for every symbol of the platform, with
SubscribeToAllTicks (callback model); use StreamTicks for the stream model.
connection.on("OnTick", data => console.log(data));
Accrued ticks of a symbol subscribed with SubscribeToTicksBatch.
Sent at the subscriber's interval or as soon as its batch size is reached,
instead of one event per tick. Batched subscriptions receive this event only,
never OnTick.
connection.on("OnTicksBatch", data => console.log(data));
Account record added, changed, deleted, archived or restored, for subscriptions made
with SubscribeToUsers. The payload is slim by design — no passwords, OTP secrets or
MQID are ever pushed.
connection.on("OnUser", data => console.log(data));
Position record opened, changed or closed, for subscriptions made with
SubscribeToPositions. A closed position arrives as a delete with zeroed volume and
open price.
connection.on("OnPosition", data => console.log(data));
Symbol configuration added, changed or deleted, for subscriptions made with
SubscribeToSymbols. Only the trading-relevant fields are pushed; session calendars and
tick filters stay on the REST surface.
connection.on("OnSymbol", data => console.log(data));
The trade server finished pushing the full symbol snapshot; the client's view of the
symbol list is complete from this point on.
connection.on("OnSymbolSync", data => console.log(data));
Payloads
The data the events and streams carry, with JSON property names as sent. A type marked or null
may be null; every other field is always present. A value of a list type is an array.
MT5TickPayload
Market tick of one symbol on the bound trade platform.
Property
Type
Description
symbol
string
Instrument name as reported by the trade server.
bid
number
Best bid price of the tick.
ask
number
Best ask price of the tick.
last
number
Price of the last committed transaction; zero when the price feed carries none.
lastTime
string (date-time)
Tick time in the trade server's time zone.
volumeExt
integer
Tick volume with extended precision, as supplied by the data provider.
flags
string
Names of the set tick flags, for example Bid, Ask.
MT5MarginCallPayload
Margin-call or stop-out event for an account.
Property
Type
Description
login
integer
Account login.
type
string
Which level the event is about: MarginCall or StopOut.
direction
string
Enter when the account reached that level, Leave when it left it.
MT5ConnectionStatusPayload
Whether WebAPI is connected to the trade platform behind the hub, sent once right after the client connects and again at every change.
Property
Type
Description
connected
boolean
true while the connection to the trade platform is up.
MT5TicksBatchPayload
Accrued ticks of one symbol, sent instead of one event per tick.
Property
Type
Description
symbol
string
Instrument the ticks belong to, as reported by the trade server.
Names of the set access rights, for example Trader, Manager.
leverage
integer
Account leverage, 1:1 is reported as 1.
balance
number or null
Account balance in the deposit currency.
credit
number or null
Credit granted to the account.
agent
integer or null
Login of the agent account, when the account is an agent's client.
clientId
integer or null
Identifier of the trading client record, when the server has one.
language
integer or null
Server-side language identifier of the account.
registration
string (date-time) or null
When the account was created, in the server's time zone.
lastAccess
string (date-time) or null
Last known connection time of the account.
lastPassChange
string (date-time) or null
When the password was last changed.
MT5UserUpdateKind
Kind of a user-record change, in the order the trade server reports it.
Sent as one of these names:
Value
Meaning
Added
The account was created.
Updated
The account was modified.
Deleted
The account was deleted.
Archived
The account was moved to the archive.
Restored
The account was restored from the archive.
MT5DealUpdatePayload
A completed trading operation. Fields follow the trade server's deal record: prices and volumes are in the server's units, volume is exact in VolumeExt.
Identifier assigned by an external system, when the order came through a gateway.
login
integer or null
Account login the order belongs to.
dealer
integer or null
Login of the dealer who placed the order, when it was dealer-placed.
partyId
integer or null
Identifier of the party the order was placed with.
symbol
string or null
Instrument the order is placed on.
digits
integer or null
Price precision of the instrument at placement time.
digitsCurrency
integer or null
Precision of the deposit currency.
contractSize
number or null
Contract size of the instrument at placement time.
state
string or null
Order state (placed, partially filled, filled, cancelled, …).
reason
string or null
Why the order was placed (client request, stop loss, take profit, …).
type
string or null
Order type (market, limit, stop, stop limit, …).
typeFill
string or null
Execution mode declared by the order (fill or kill, immediate or cancel, …).
typeTime
string or null
Expiration mode of the order (good till cancelled, day, specified, …).
timeSetup
string (date-time) or null
When the order was placed, in the trade server's time zone.
timeExpiration
string (date-time) or null
When the order expires.
timeDone
string (date-time) or null
When the order reached its final state.
timeSetupMsc
string (date-time) or null
Placement time with millisecond precision.
timeDoneMsc
string (date-time) or null
Final-state time with millisecond precision.
priceOrder
number or null
Price specified in the order.
priceTrigger
number or null
Activation price of a stop-limit order.
priceCurrent
number or null
Current market price of the instrument.
priceSl
number or null
Stop-loss price carried by the order.
priceTp
number or null
Take-profit price carried by the order.
volumeInitial
integer or null
Requested volume in the server's units.
volumeCurrent
integer or null
Unfilled remainder in the server's units.
volumeInitialExt
integer or null
Requested volume with extended precision.
volumeCurrentExt
integer or null
Unfilled remainder with extended precision.
expertId
integer or null
Identifier of the expert advisor that placed the order, when there was one.
positionId
integer or null
Position identifier the order belongs to.
comment
string or null
Free-form comment of the order.
rateMargin
number or null
Currency conversion rate applied to the margin.
MT5OrderUpdateKind
Kind of an order change.
Sent as one of these names:
Value
Meaning
Added
The order was placed.
Updated
The order was modified.
Deleted
The order was removed.
MT5SyncPayload
The trade server finished pushing a full snapshot, so the client's view is complete. The event carries no data: the platform is already known from the connection.
An empty object: the event is a marker, it carries no data.
MT5PositionUpdatePayload
An open position and its state. A deleted position arrives with zeroed volume and open price, which is how the trade server reports a closed position.
Position identifier, unique within the trade server.
externalId
string or null
Identifier assigned by an external system, when the position came through a gateway.
login
integer or null
Account login the position belongs to.
symbol
string or null
Instrument the position is open on.
action
string or null
Position direction (buy or sell).
reason
string or null
Why the position was opened (client request, …).
timeCreate
string (date-time) or null
When the position was opened, in the trade server's time zone.
timeUpdate
string (date-time) or null
When the position last changed.
timeCreateMsc
string (date-time) or null
Opening time with millisecond precision.
timeUpdateMsc
string (date-time) or null
Last-change time with millisecond precision.
priceOpen
number or null
Volume-weighted open price.
priceCurrent
number or null
Current market price of the instrument.
priceSl
number or null
Stop-loss price of the position.
priceTp
number or null
Take-profit price of the position.
volume
integer or null
Position volume in the server's units.
volumeExt
integer or null
Position volume with extended precision.
profit
number or null
Current profit in the deposit currency.
storage
number or null
Accrued storage charge.
rateProfit
number or null
Currency conversion rate applied to the profit.
rateMargin
number or null
Currency conversion rate applied to the margin.
expertId
integer or null
Identifier of the expert advisor that opened the position, when there was one.
expertPositionId
integer or null
Identifier the expert advisor assigned to the position.
comment
string or null
Free-form comment of the position.
dealer
integer or null
Login of the dealer who opened the position, when it was dealer-opened.
activationMode
string or null
How the position is activated (by price, by time, …).
activationTime
string (date-time) or null
Activation time, when the position is time-activated.
activationPrice
number or null
Activation price, when the position is price-activated.
modificationFlags
string or null
Names of the set modification flags of the position.
MT5PositionUpdateKind
Kind of a position change.
Sent as one of these names:
Value
Meaning
Added
The position was opened.
Updated
The position was modified.
Deleted
The position was closed.
MT5SymbolUpdatePayload
Symbol-configuration state transition. Surfaces the trading-relevant fields only: session calendars, tick filters, instant-execution internals, splice and option settings are not pushed over the hub; subscribers that need them should use the REST surface.