Solution · MetaTrader Bridge
MT4 / MT5 External Data Feed: Bring Stocks, Indices and Crypto into MetaTrader
MetaTrader only shows what your broker quotes. With iTick as an external feed, a small Python service streams real-time prices into MT5 custom symbols (or an MT4 bridge), so you can chart, alert and run Expert Advisors on US and Hong Kong stocks, global indices and crypto.
- Real-time ticks into MT5 Custom Symbols via CustomTicksAdd
- MT4 support through offline charts or your bridge plugin
- Stocks, global indices, forex, metals and crypto
- Historical K-lines to backfill charts and test EAs
# Python bridge: iTick WebSocket -> ZeroMQ PUB -> MetaTrader EA
import json, time, websocket, zmq # pip install websocket-client pyzmq
pub = zmq.Context().socket(zmq.PUB)
pub.bind("tcp://127.0.0.1:5556") # EA subscribes here
def on_message(ws, msg):
d = json.loads(msg).get("data") or {}
if d.get("s") and "ld" in d:
# one line per tick: SYMBOL time_ms bid ask last
bid, ask = d.get("b", d["ld"]), d.get("a", d["ld"])
pub.send_string(f'{d["s"]} {d.get("t", int(time.time()*1000))} {bid} {ask} {d["ld"]}')
def on_open(ws):
ws.send(json.dumps({"ac": "subscribe",
"params": "AAPL$US,NVDA$US,700$HK",
"types": "quote"}))
while True: # auto-reconnect
websocket.WebSocketApp("wss://api.itick.org/stock", header={"token": "YOUR_API_TOKEN"},
on_open=on_open, on_message=on_message).run_forever(ping_interval=20)
time.sleep(3)Why traders bridge iTick into MetaTrader
Keep the platform and EAs you know, and widen the instruments and data quality behind them.
Instruments your broker lacks
US and HK equities, Asian indices and crypto pairs as custom symbols next to your FX charts.
Fix delayed foreign quotes
Replace slow or delayed offshore quotes with a direct real-time feed.
Run EAs on new markets
Attach existing Expert Advisors and indicators to bridged symbols without rewriting them.
Backfill history
Load K-line history into custom symbols with CustomRatesUpdate for indicators and the Strategy Tester.
Resilient bridge
Auto-reconnecting WebSocket client, heartbeat and local fan-out to several terminals.
Clean, consistent ticks
Bid, ask and last with millisecond timestamps in one format for every market.
How the bridge works
Four small pieces, all running on your VPS or desktop.
- 1
iTick WebSocket
Subscribe to symbols such as AAPL$US or 700$HK.
- 2
Python bridge
Normalize ticks and publish them on a local ZeroMQ socket.
- 3
MT5 EA / MT4 plugin
Receive ticks and write them with CustomTicksAdd or your bridge.
- 4
Charts and EAs
Custom symbols update live; indicators and EAs run as usual.
MT5 vs MT4 integration
MT5 has native custom symbols; MT4 needs a workaround.
| MetaTrader 5 | MetaTrader 4 | |
|---|---|---|
| Live prices | CustomTicksAdd on a custom symbol | Offline chart or third-party bridge plugin |
| History backfill | CustomRatesUpdate from iTick K-lines | Write .hst history files |
| Run EAs | Yes, on the custom symbol | Yes, on the offline chart |
| Strategy Tester | Supported on custom symbols | Limited |
Order execution still goes through your broker; bridged symbols are for charting, signals and analysis unless your broker offers the same instrument.
Bridge sample code
A Python publisher and the MQL5 side that writes ticks into a custom symbol.
- Get a free iTick API token
- Run the Python bridge on the same machine as MetaTrader
- Attach the EA to create and update the custom symbol
# Python bridge: iTick WebSocket -> ZeroMQ PUB -> MetaTrader EA
import json, time, websocket, zmq # pip install websocket-client pyzmq
pub = zmq.Context().socket(zmq.PUB)
pub.bind("tcp://127.0.0.1:5556") # EA subscribes here
def on_message(ws, msg):
d = json.loads(msg).get("data") or {}
if d.get("s") and "ld" in d:
# one line per tick: SYMBOL time_ms bid ask last
bid, ask = d.get("b", d["ld"]), d.get("a", d["ld"])
pub.send_string(f'{d["s"]} {d.get("t", int(time.time()*1000))} {bid} {ask} {d["ld"]}')
def on_open(ws):
ws.send(json.dumps({"ac": "subscribe",
"params": "AAPL$US,NVDA$US,700$HK",
"types": "quote"}))
while True: # auto-reconnect
websocket.WebSocketApp("wss://api.itick.org/stock", header={"token": "YOUR_API_TOKEN"},
on_open=on_open, on_message=on_message).run_forever(ping_interval=20)
time.sleep(3)MetaTrader data bridge FAQ
Can I add stocks to MT5 that my broker does not offer?
Yes, as custom symbols for charting and analysis. MT5 lets an EA create a custom symbol and push ticks into it with CustomTicksAdd; iTick provides the real-time prices.
Does this work with MT4?
MT4 has no native custom symbols, so prices are shown through offline charts or a bridge plugin. The Python side of the bridge is the same.
Can I trade the bridged symbols?
Orders are executed by your broker. If the broker does not list the instrument, use the bridged symbol for signals and place orders on an instrument you can trade.
Do you provide the bridge?
iTick provides the data API and sample bridge code. For a managed or customized bridge for your firm, contact our team.
Put new markets on your MetaTrader charts
Get a free API key and run the bridge sample in minutes.