MetaTrader 5 APIAccount data
For AI agents: this page is also available as Markdown at /docs/mt5/account-data.md. The index of every docs page is /docs/llms.txt.
MetaTrader 5 Account Data & Status API
Read live and static state for a connected MetaTrader 5 account: balance and equity, the static account configuration, open positions and pending orders, trade and position history, and a single connection-health endpoint to confirm the account is logged in and trading-ready.
How account data works on MT5
- Netting or hedging. MT5 accounts come in both kinds; read marginMode from /AccountInfo before trading. On a netting account all trades on a symbol add up to one position, on a hedging account each trade is its own position.
- Orders, deals and positions are separate. An order is the request, a deal is an execution, a position is what stays open. /OrderHistory returns deals, with entry In, Out, InOut (a reversal on netting accounts) or OutBy, and position links the deals of one round trip.
- Round trips are reassembled. /PositionHistory groups the deals of each position into one row with volume-weighted open and close prices, so a position closed in several parts is still one row.
- Broker latency included. /status reports pingMs, the terminal's last measured round trip to the broker.
/mt5/{account_id}/AccountSummarySnapshot of the connected trading account: balance, credit, floating profit, equity, margin, free margin, margin level, leverage, account currency, and account type. Reflects broker-side state at call time, no caching.
curl -H "X-API-Key: fxs_live_..." \
https://api.fxsocket.com/mt5/{account_id}/AccountSummary{
"balance": 9686.15,
"credit": 0.0,
"profit": 0.0,
"equity": 9686.15,
"margin": 0.0,
"freeMargin": 9686.15,
"marginLevel": 0.0,
"leverage": 400,
"currency": "USD",
"type": "Demo"
}/mt5/{account_id}/AccountInfoStatic identity and configuration of the account: the who-and-how that rarely changes, as opposed to the live financials in /AccountSummary. Includes the account holder name, login, broker company and server, currency, leverage, account type, margin mode (Netting / Hedging / Exchange, needed to know whether an opposite order nets a position or opens a new one), stop-out configuration, and trade permissions.
curl -H "X-API-Key: fxs_live_..." \
https://api.fxsocket.com/mt5/{account_id}/AccountInfo{
"name": "Lars Joeressen",
"login": 2100152454,
"server": "TegasFX-Demo",
"company": "TegasFX Ltd",
"currency": "USD",
"currencyDigits": 2,
"leverage": 200,
"type": "Demo",
"marginMode": "Hedging",
"marginSoMode": "Percent",
"marginCallLevel": 100.0,
"stopOutLevel": 70.0,
"tradeAllowed": true,
"tradeExpert": true,
"limitOrders": 200,
"fifoClose": false
}/mt5/{account_id}/OpenedOrdersAll open positions and active pending orders: one row per position (already-filled trade) and one per pending order (limit / stop / stop-limit). kind discriminates the two; pending orders show their trigger price in openPrice and carry zero swap/profit. For a pending order's stop-limit price, volumes and expiry, use /PendingOrders.
curl -H "X-API-Key: fxs_live_..." \
https://api.fxsocket.com/mt5/{account_id}/OpenedOrders[{
"ticket": 211438758,
"symbol": "USDJPY",
"type": "Sell",
"kind": "position",
"lots": 0.1,
"openPrice": 160.505,
"currentPrice": 160.547,
"stopLoss": 160.576,
"takeProfit": 160.458,
"swap": 0.0,
"profit": -2.62,
"magic": 0,
"comment": "",
"openTime": "2026-06-11T11:02:04.000Z"
}, {
"ticket": 211583734,
"symbol": "GBPUSD",
"type": "BuyStop",
"kind": "pending",
"lots": 0.01,
"openPrice": 1.34958,
"currentPrice": 1.33683,
"stopLoss": 1.34611,
"takeProfit": 1.35275,
"swap": 0.0,
"profit": 0.0,
"magic": 0,
"comment": "",
"openTime": "2026-06-10T09:30:00.000Z"
}]/mt5/{account_id}/PendingOrdersActive pending orders only, with everything needed to copy or rebuild one: the stop-limit price, the volume it was placed with and the volume still to fill, stops, and its expiry. expirationMode is gtc (until cancelled), day (end of the trading day), specified (at expiration) or specifiedDay (end of that day). expiration is broker server time like every other time field and empty when the order doesn't expire; expirationUtc and timeUtc are the same moments in real UTC.
curl -H "X-API-Key: fxs_live_..." \
https://api.fxsocket.com/mt5/{account_id}/PendingOrders[{
"ticket": 211583734,
"symbol": "GBPUSD",
"type": "BuyStopLimit",
"volumeInitial": 0.1,
"volume": 0.1,
"price": 1.34958,
"stopLimitPrice": 1.34900,
"sl": 1.34611,
"tp": 1.35275,
"expirationMode": "specified",
"expiration": "2026-11-03T19:00:00.000Z",
"expirationUtc": "2026-11-03T17:00:00.000Z",
"magic": 0,
"comment": "",
"time": "2026-11-03T09:30:00.000Z",
"timeUtc": "2026-11-03T07:30:00.000Z"
}]/mt5/{account_id}/OrderHistoryClosed deals in a time range. Returns DEAL entries (executions), not ORDER entries; pending orders that never filled don't appear here. Omit both bounds to fetch all-time history.
from: Inclusive lower bound (broker server time). ISO-8601 (2026-01-01T00:00:00Z) or YYYY-MM-DD. Absent → epoch.to: Inclusive upper bound, same formats. Absent → now.
curl -H "X-API-Key: fxs_live_..." \
"https://api.fxsocket.com/mt5/{account_id}/OrderHistory?from=2026-01-01&to=2026-12-31"[{
"ticket": 211438992,
"order": 211438991,
"symbol": "EURUSD",
"type": "Sell",
"entry": "Out",
"volume": 0.1,
"price": 1.15410,
"commission": -0.40,
"swap": 0.0,
"profit": 12.00,
"magic": 0,
"comment": "",
"time": "2026-06-10T15:42:11Z"
}]/mt5/{account_id}/PositionHistoryClosed positions in a time range: one row per round-trip trade (open → close), reconstructed from the underlying deals with volume-weighted open/close prices. Use this when you want net results per position; use /OrderHistory when you need the raw deal log. Omit both bounds to fetch all-time history.
from: Inclusive lower bound (broker server time). ISO-8601 (2026-01-01T00:00:00Z) or YYYY-MM-DD. Absent → epoch.to: Inclusive upper bound, same formats. Absent → now.
curl -H "X-API-Key: fxs_live_..." \
"https://api.fxsocket.com/mt5/{account_id}/PositionHistory?from=2026-01-01&to=2026-12-31"[{
"positionId": 211438758,
"symbol": "EURUSD",
"type": "Buy",
"volume": 0.1,
"openTime": "2026-06-10T09:12:04.000Z",
"openPrice": 1.15201,
"closeTime": "2026-06-10T15:42:11.000Z",
"closePrice": 1.15410,
"profit": 20.90,
"swap": 0.0,
"commission": -0.80,
"netProfit": 20.10,
"magic": 0,
"comment": ""
}]/mt5/{account_id}/statusFull connection health of the terminal, in one call: is the terminal alive, is it connected to the broker, and is the account logged in? Use this to confirm an account is live and trading-ready before sending orders. Always returns HTTP 200; read the body to see the actual state. The top-level status is ready (everything healthy and the account logged in), starting (still booting / logging in), degraded (e.g. broker disconnected), or down. For lightweight probes there are also two unauthenticated routes that signal via HTTP status code: GET /healthz (200 once fully ready, 503 otherwise) and GET /livez (200 while the terminal is alive, regardless of broker connection). bridge.version is the version of the terminal software: pending-order streaming, the trade replay, clientOrderId and the UTC time fields need 0.17.0 or later.
curl -H "X-API-Key: fxs_live_..." \
https://api.fxsocket.com/mt5/{account_id}/status{
"status": "ready",
"terminal": { "alive": true, "build": 5180, "pingMs": 42 },
"broker": { "connected": true, "server": "TegasFX-Demo" },
"account": {
"loggedIn": true,
"login": 2100152454,
"currency": "USD",
"type": "Demo",
"tradeAllowed": true
},
"bridge": { "version": "0.17.0", "tradeEaReady": true, "symbolsSynced": true },
"serverTime": "2026-06-11T08:55:57.000Z"
}