MetaTrader WebSocket API. Every tick, as it lands.
One socket per account pushes prices, fills, deals and account state the moment the terminal sees them. Send orders down the same connection.
$15 per account, per month. MT5 today, MT4 next.
import WebSocket from "ws" const socket = new WebSocket( `wss://wss.pipsocket.com/v1/accounts/${process.env.ACCOUNT}/stream`, { headers: { Authorization: `Bearer ${process.env.PIPSOCKET_KEY}` } }, ) socket.on("open", () => socket.send(JSON.stringify({ id: "t1", method: "PUT", path: "/ticks", body: { symbols: ["EURUSD", "XAUUSD"] }, }))) socket.on("message", (data) => console.log(JSON.parse(data.toString())))
import asyncio, json, os, websockets async def main(): url = f"wss://wss.pipsocket.com/v1/accounts/{os.environ['ACCOUNT']}/stream" headers = {"Authorization": f"Bearer {os.environ['PIPSOCKET_KEY']}"} async with websockets.connect(url, additional_headers=headers) as socket: await socket.send(json.dumps({"id": "t1", "method": "PUT", "path": "/ticks", "body": {"symbols": ["EURUSD", "XAUUSD"]}})) async for message in socket: print(json.loads(message)) asyncio.run(main())
Receiving
{"type":"tick","symbol":"EURUSD","bid":1.08412,"ask":1.08414}
{"type":"tick","symbol":"XAUUSD","bid":2391.80,"ask":2392.10}
{"type":"request","state":"done","result":{"retcode":10009}}
{"type":"tick","symbol":"EURUSD","bid":1.08415,"ask":1.08417}
{"type":"account","equity":10482.16,"margin":108.41}
- Prices as the broker sends them
- Bid, ask and last on every change, for up to 100 symbols per account.
- Your fills, however you sent them
- A REST call, a TradingView alert or the kill switch: each result lands on the stream.
- Calls on the same socket
- Send any API call as a message and get the REST answer back, matched by your id.
- No silent gaps
- Fall behind and you get a lagged event with the count, so you know to re-read state.
Everything on the account, in one socket.
Every message is a JSON object with a type. Fields follow MT5's own: MqlTick for prices, OnTradeTransaction for changes.
wss.pipsocket.com/v1/accounts/{account}/stream
Events pushed to you
- push
tickBid, ask and last for the symbols you picked - push
requestA trade settled: filled, rejected or refused - push
dealA fill, close, stop loss or take profit - push
accountBalance, equity and margin, every second
Status, and calls you send
- push
transactionOrders and positions changing, from MT5 - push
statusThe terminal connecting or disconnecting - push
laggedThe stream fell behind, with how many missed - send
PUT /ticksPick the symbols to stream, up to 100 - send
POST /ordersAny REST call, answered on the socket
From MetaTrader login to live prices. Three steps, no polling.
Connect your MT5 login
Server, login and password, from any MT5 broker. Your terminal starts next to your broker's trade server and stays on.
Make your API key
One key for your workspace, shown once. Keep it on your server and roll it whenever you like.
Open the stream
Connect with your key in the header, send the symbols you want, and events start arriving.
Why not poll, or run a socket EA?
| Polling, or a socket EA on a VPS | Pipsocket WebSocket | |
|---|---|---|
| Prices | A request a second, and you still miss moves | Each price change pushed as the broker sends it |
| Your fills | Poll positions and diff them yourself | A request event the moment MT5 answers |
| Falling behind | Gaps you find out about later | A lagged event with how many you missed |
| Security | A port open on the VPS for the EA's socket | No open ports. Terminals dial out; your key opens the stream. |
| Trading | A second channel just for orders | Orders on the same socket, idempotent like REST |
MetaTrader WebSocket questions
Something else? The stream docs list every event and field.
- Can I stream MT5 prices without running a terminal?
- Yes. Pipsocket runs the MT5 terminal on its servers and streams it to you. All you need is an MT5 login from your broker.
- How many symbols can I stream?
- Up to 100 per account, shared by that account's streams. Change the set any time with one call.
- Can I connect from a browser?
- Not directly. The key goes in the Authorization header of the upgrade, which browsers can't set, so connect from your server.
- What happens if my connection drops?
- Reconnect and send your symbols again. Events from the gap aren't replayed, so read positions and history over REST.
- What does it cost?
- $15 per account, per month, with REST, TradingView alerts, MCP and the kill switch included. No per-message fees.