MT5 Semantics
Handle hedging and netting accounts, richer symbol metadata, and more detailed history access than MT4.
Build richer account automation on MetaTrader 5 with expanded order semantics, history access, and streaming telemetry.
Handle hedging and netting accounts, richer symbol metadata, and more detailed history access than MT4.
Use history, deals, equity curves, and performance metrics to power scorecards and investor dashboards.
Keep trade automation and account telemetry aligned through a shared bridge session and event stream.
MT5 follows the same session bootstrap pattern as MT4, but exposes a wider order model and richer account metadata once connected.
You can move from credential exchange to quote streaming and first trade placement in three calls.
curl https://api.metatraderapi.xyz/mt5/client/orders \
-H "Authorization: Bearer <api-key>" \
-H "x-session-id: sess_live_0191" \
-d '{
"symbol": "XAUUSD",
"type": "SELL_LIMIT",
"price": 2318.40,
"volume": 0.10
}'MT5 supports netting and hedging account modes, advanced pending orders, volume granularity, and extended trade metadata.
Use task receipts to correlate your internal strategy events with actual broker-side order lifecycle updates.
Query orders, deals, balances, equity changes, and position history for reporting and audit pipelines.
History endpoints are optimized for windowed fetches, making them suitable for scheduled ETL tasks.
The MT5 client surface also exposes drawdown, Sharpe ratio, expectancy, win-rate, and profit-factor calculations so you can embed analytics directly into your product.
Use these endpoints for daily rollups, strategy scorecards, or investor dashboards.
The MT5 client surface uses the same workspace API key and bridge session model as MT4, but exposes more account metadata once connected.
Prefer session warm-up, symbol prefetch, and explicit request ids before launching batch trade or reporting flows.
| Header | Value | Use | Description |
|---|---|---|---|
| Authorization | Bearer <api-key> | Required | Workspace API key created for the target environment. |
| x-session-id | sess_mt5_live_07 | Required | MT5 bridge session identifier. |
| x-request-id | req_stats_2101 | Recommended | Idempotency key for writes and batch fetches. |
| Accept-Language | en-US | Optional | Use when normalizing locale-sensitive symbol metadata. |
| Method | Path | Purpose |
|---|---|---|
| POST | /session/open | Bootstrap an MT5 bridge session. |
| GET | /account | Inspect account metadata and trading permissions. |
| GET | /symbols | List enabled instruments and contract settings. |
| GET | /symbols/{symbol} | Read detailed symbol parameters. |
| Method | Path | Purpose |
|---|---|---|
| POST | /orders | Submit market, limit, stop, or stop-limit tasks. |
| GET | /positions | Read current positions for hedging or netting accounts. |
| GET | /history/deals | Read deal history for reconciliation. |
| GET | /history/equity | Fetch equity timeline for charts or daily rollups. |
| Method | Path | Purpose |
|---|---|---|
| GET | /stats/performance | Compute drawdown, Sharpe, expectancy, and profit factor. |
| GET | /orders/history | Retrieve historical orders and state transitions. |
| WS | /events | Receive quote, order, and position updates in real time. |
| GET | /events/tester | Open a built-in browser tester for stream diagnostics. |
MT5 writes return task receipts first and broker execution details later. Keep a durable mapping between your strategy event id and the API task id.
Historical endpoints are optimized for windowed reads. Paginate large backfills to avoid rate limiting or oversized responses.
| Code | Name | Meaning |
|---|---|---|
| 400 | ValidationError | Payload, symbol, or trade parameters failed validation. |
| 401 | Unauthorized | API key or session token is missing, expired, or revoked. |
| 409 | TaskConflict | The same external request id was replayed with different payload data. |
| 429 | RateLimited | Workspace or account throughput limits were exceeded. |
| 502 | BridgeUnavailable | The bridge lost connectivity to the terminal or broker server. |
For analytics-heavy workloads, isolate history reads from execution workers so reporting jobs do not compete with live order placement.
Use the built-in events tester and a dedicated stream health monitor to validate account subscriptions before routing live traffic.