Deploy MT5¶
Live trading routes orders through a per-broker mt5-gateway HTTP service that runs MT5 in Wine inside Docker. Phase 17 shipped the broker; Phase 18 wired the dispatch into LiveSession; Phase 20 packaged the full stack.
Prerequisites¶
- Docker + Docker Compose
- An MT5 broker account (Exness, ICMarkets, FTMO, Pepperstone, etc.)
- Server name from your broker (e.g.
Exness-MT5Real8)
1. Spin up the stack¶
cp .env.example .env
# Edit .env: MT5_LOGIN, MT5_PASSWORD, MT5_SERVER, VNC_PASSWORD
cp qkt.config.yaml.example qkt.config.yaml
# Adjust profile entries if you're not using Exness
docker compose up -d
The compose file (docker-compose.yml) starts:
mt5-gatewayon ports 3000 (VNC) + 5001 (HTTP API)qktdaemon, depends-on healthy gateway
2. Log in to MT5¶
The first time you start the gateway, you have to log in to MT5 through the VNC GUI:
- Connect to
localhost:3000with a VNC client. - Use the
VNC_PASSWORDfrom.env. - In the MT5 window, log in with your broker account.
After login, curl http://localhost:5001/health should return {"status":"ok"}. The qkt daemon's depends_on healthcheck waits for this.
3. Configure the broker profile¶
Built-in defaults cover Exness, ICMarkets, FTMO, Pepperstone. To use Exness, the minimum config is:
The gateway_url matches the Docker service name. On a non-Docker setup, use http://localhost:5001.
For multi-account, distinct profiles via extends: — see the configure-mt5-broker recipe.
4. Verify what's loaded¶
Should show your exness profile with the resolved gateway URL.
5. Write a live strategy¶
STRATEGY live_eur VERSION 1
SYMBOLS
eur = EXNESS:EURUSD EVERY 1m
RULES
WHEN ema(eur, 9) crosses ABOVE ema(eur, 21)
THEN BUY eur SIZING 0.01 BRACKET STOP_LOSS BY 30 PCT TAKE_PROFIT BY 60 PCT
The EXNESS: prefix routes orders to the configured profile.
6. Deploy¶
docker compose exec qkt qkt deploy /strategies/live_eur.qkt --as live_eur
docker compose exec qkt qkt status live_eur
docker compose exec qkt qkt logs live_eur --follow
7. Pre-launch tick audit¶
Before committing real money, run the tick-feed drift check:
Reports the absolute price difference between TradingView ticks (what your strategies see) and MT5 ticks (where orders fill). If p95 abs diff is wider than your stop-loss buffer, tighten or widen accordingly.
Tear down¶
Common issues¶
- Gateway returns 502. MT5 isn't logged in. Connect to VNC and log in through the GUI.
- Symbol not found. Verify the broker's actual symbol via the MT5 market watch — Exness uses
msuffix (EURUSDm), ICMarkets uses.raw. TheMT5Symboltranslator handles this if your profile is right. - Orders rejected with retcode 10018. Market closed (weekend / outside session). Wait for the broker's session.
Next¶
- Concepts: broker integration — capability matrix, fallback paths, magic semantics
- Operations: deploy with Docker — production-grade deploy patterns