MetaTrader 4 APIMarket data

For AI agents: this page is also available as Markdown at /docs/mt4/market-data.md. The index of every docs page is /docs/llms.txt.

MetaTrader 4 Market Data API

Pull MetaTrader 4 market data over REST: the broker's symbol list, latest quotes, full contract specifications, OHLC price history for any timeframe, and broker server time. For a continuous tick feed, use the WebSocket prices stream instead of polling.

How market data works on MT4

  • Tick volume only. MT4 records how many price changes a bar had, not traded volume: realVolume in /PriceHistory is always 0, and tickVolume is the number to use.
  • Quotes carry no last price. In /getQuote, last is always 0, and volume is the tick count of the current M1 bar.
  • Symbols must actually quote. A symbol that shows no bid or ask within about half a second is rejected instead of returning zeros. That usually means the plain name (EURUSD) on a broker that only quotes a suffixed one (EURUSD.sd); look the name up in /symbols.
  • Warm symbols before trading. Adding a symbol to Market Watch and waiting for its first quote takes MT4 a moment. /SymbolSelect does it for up to 100 symbols in one call, much faster than one by one, so the first order on each one doesn't have to.
  • Broker-dependent contract fields. In /SymbolInfo, the base, profit and margin currencies and the description come from the broker's MT4 symbol settings and can be empty.
GET /mt4/{account_id}/symbols

Names of all symbols available in Market Watch. Use the returned names verbatim with /getQuote, /SymbolInfo, /PriceHistory, and /OrderSend, since many brokers suffix their symbols (EURUSD.sd, XAUUSD.r), so discover the exact spelling here instead of assuming plain names. A symbol not in Market Watch can't stream ticks until it's added, but a getQuote call enables it on demand, and /SymbolSelect adds up to 100 at once.

Example request
curl -H "X-API-Key: fxs_live_..." \
  https://api.fxsocket.com/mt4/{account_id}/symbols
Response
["EURUSD.sd", "GBPUSD.sd", "USDJPY.sd", "XAUUSD.sd", "..."]
GET /mt4/{account_id}/getQuote

Latest tick for a symbol: the most recent bid, ask, last, volume, and broker server time. If the symbol isn't yet in Market Watch it's enabled on demand, which may add a small delay on the first call. On MT4, last is always 0 and volume is the tick count of the current M1 bar. A symbol that shows no live quote within about half a second is rejected, typically an unsuffixed name such as EURUSD on a broker that only quotes EURUSD.sd. For continuous ticks use the WebSocket prices topic instead.

  • symbol (required): Symbol name as listed by /symbols (e.g. EURUSD, XAUUSD).
Example request
curl -H "X-API-Key: fxs_live_..." \
  "https://api.fxsocket.com/mt4/{account_id}/getQuote?symbol=EURUSD"
Response
{
  "symbol": "EURUSD",
  "bid": 1.15325,
  "ask": 1.15333,
  "time": "2026-06-11T08:55:56.728Z",
  "last": 0.0,
  "volume": 37
}
GET /mt4/{account_id}/PriceHistory

OHLC bars for a symbol and timeframe: one candle per bar in the requested window. MT4 fetches missing history from the broker on demand, so wide ranges on small timeframes can take several seconds. An empty response is normal when the window predates the broker's retained history or covers a closed market. realVolume is always 0 on MT4, which only records tick volume.

  • symbol (required): Symbol name as listed by /symbols.
  • timeframe (required): MT4 labels (M1, M5, M15, M30, H1, H4, D1, W1, MN1) or human forms (5min, 1h, 1d).
  • from: Inclusive lower bound (broker server time). ISO-8601 or YYYY-MM-DD. Absent → epoch.
  • to: Inclusive upper bound, same formats. Absent → now.
Example request
curl -H "X-API-Key: fxs_live_..." \
  "https://api.fxsocket.com/mt4/{account_id}/PriceHistory?symbol=EURUSD&timeframe=H1&from=2026-01-01&to=2026-12-31"
Response
[{
  "time": "2026-06-11T08:00:00Z",
  "open": 1.15301,
  "high": 1.15348,
  "low": 1.15289,
  "close": 1.15330,
  "tickVolume": 1243,
  "realVolume": 0,
  "spread": 7
}]
GET /mt4/{account_id}/SymbolInfo

Contract specification for a symbol: digits, point, spread, contract size, tick size/value, volume min/max/step, trade mode, swap rates, base/quote/margin currencies, and what can be traded on it. On MT4 those are a fixed set: orderModes market, limit, stop, sl, tp and closeBy (no stopLimit), expirationModes gtc and specified, and no fillingModes. Call this before /OrderSend to validate volumes and round prices to the right precision. On MT4 the base, profit and margin currencies and the description come from the broker's symbol settings and can be empty on some brokers. Pass symbols instead of symbol to look up to 100 at once: the reply is then {"symbols": [...], "errors": [...]}, and a symbol that fails lands in errors with its own symbol, error code and message instead of failing the whole request.

  • symbol: Symbol name as listed by /symbols. Required unless symbols is given.
  • symbols: Comma-separated list of up to 100 symbols, instead of symbol.
Example request
curl -H "X-API-Key: fxs_live_..." \
  "https://api.fxsocket.com/mt4/{account_id}/SymbolInfo?symbol=EURUSD"
Response
{
  "symbol": "EURUSD",
  "description": "1 Lot= 100,000 EUR",
  "digits": 5,
  "point": 0.00001,
  "tickSize": 0.00001,
  "tickValue": 1.0,
  "contractSize": 100000.0,
  "volumeMin": 0.01,
  "volumeMax": 150000.0,
  "volumeStep": 0.01,
  "stopsLevel": 1,
  "freezeLevel": 0,
  "spread": 7,
  "tradeMode": "Full",
  "swapLong": -3.22,
  "swapShort": 1.1,
  "bid": 1.15324,
  "ask": 1.15331,
  "currencyBase": "EUR",
  "currencyProfit": "USD",
  "currencyMargin": "EUR",
  "orderModes": ["market", "limit", "stop", "sl", "tp", "closeBy"],
  "expirationModes": ["gtc", "specified"],
  "fillingModes": []
}
POST /mt4/{account_id}/SymbolSelect

Put up to 100 symbols into Market Watch in one call, then wait once, at most a second, until the newly added ones quote. Send a strategy's or a copier's symbols before its first order, so that order doesn't wait for a cold symbol: on MT4, six cold symbols took about 250 ms in one call, against about 200 ms each when looked up one by one. selected false means the broker has no symbol by that name; quoting false means it was added but had no price yet within that second (or the broker lists it without a feed). A read-only key gets a 403 here, since the call changes the terminal's Market Watch.

  • symbols (required): Array of up to 100 symbol names as listed by /symbols.
Request body
{
  "symbols": ["EURUSD", "GBPUSD", "XAUUSD"]
}
Example request
curl -X POST https://api.fxsocket.com/mt4/{account_id}/SymbolSelect \
  -H "X-API-Key: fxs_live_..." \
  -H "Content-Type: application/json" \
  -d '{"symbols":["EURUSD","GBPUSD","XAUUSD"]}'
Response
[
  { "symbol": "EURUSD", "selected": true, "quoting": true },
  { "symbol": "GBPUSD", "selected": true, "quoting": true },
  { "symbol": "XAUUSD", "selected": true, "quoting": false }
]
GET /mt4/{account_id}/ServerTimezone

Broker server time and its offset from UTC. Timestamps across the API are labelled Z but run on broker server time. Use utcOffsetSeconds to translate them to real UTC (utc = serverTime − utcOffsetSeconds). Most MetaTrader brokers run on EET (UTC+2, UTC+3 with DST). Fields whose names end in Utc, and the ts of stream frames, are real UTC already. Live data (trade replies, stream events, /PendingOrders) carries them next to the server time; history endpoints stay in server time only, because today's offset would be an hour off for times on the other side of a daylight-saving switch.

Example request
curl -H "X-API-Key: fxs_live_..." \
  https://api.fxsocket.com/mt4/{account_id}/ServerTimezone
Response
{
  "serverTime": "2026-06-11T08:55:57.000Z",
  "utcOffsetSeconds": 0
}