# MT5 Runbook
This MT5 install is demo-only and isolated under `/trading/forex-mt5`.
## Start, Stop, Status, Logs
Headless local-only start with Xvfb:
```bash
/trading/forex-mt5/scripts/start-mt5.sh --headless
```
Visual start over trusted SSH X11 forwarding:
```bash
ssh -Y root@YOUR_VPS_IP
DISPLAY="$DISPLAY" /trading/forex-mt5/scripts/start-mt5.sh --x11
```
Stop:
```bash
/trading/forex-mt5/scripts/stop-mt5.sh
```
Status:
```bash
/trading/forex-mt5/scripts/status-mt5.sh
```
Logs:
```bash
/trading/forex-mt5/scripts/logs-mt5.sh 50
```
Short safe soak cycle:
```bash
/trading/forex-mt5/scripts/soaktest-mt5.sh --cycles 2 --wait 20 --tail 20
```
Long safe soak cycle:
```bash
/trading/forex-mt5/scripts/soaktest-mt5.sh --profile long-2h
```
Latest log review:
```bash
/trading/forex-mt5/scripts/review-latest-logs.sh --lines 40
```
## Key Paths
- Wine prefix: `/trading/forex-mt5/wineprefix`
- Terminal install: `/trading/forex-mt5/wineprefix/drive_c/Program Files/MetaTrader 5`
- Runtime home: `/trading/forex-mt5/runtime/home`
- Wrapper logs: `/trading/forex-mt5/logs`
- Soak test logs: `/trading/forex-mt5/logs/soaktest`
- Terminal logs: `/trading/forex-mt5/wineprefix/drive_c/Program Files/MetaTrader 5/logs`
## Current Install State
- MT5 terminal binaries are present.
- Smoke test confirmed `terminal64.exe` starts under `tradingfx`.
- No public listener was opened by MT5 during validation.
- No broker or demo credential has been configured.
## Demo Login Procedure
1. Read `/trading/forex-mt5/docs/GUI-ACCESS.md`.
2. Read `/trading/forex-mt5/docs/DEMO-LOGIN-CHECKLIST.md`.
3. Confirm MT5 is stopped with `/trading/forex-mt5/scripts/status-mt5.sh`.
4. Start MT5 with `--x11` from a trusted workstation over SSH X11 forwarding.
5. Use a demo account only and keep GUI access local-only.
6. Verify the terminal is connected before touching charts or Market Watch.
7. Keep the session manual-only for this phase. Do not enable live trading and do not start crypto.
8. Close the GUI and run `/trading/forex-mt5/scripts/stop-mt5.sh` when finished.
## Demo Login Troubleshooting
### DISPLAY or X11 failed
- Reconnect with `ssh -Y root@YOUR_VPS_IP` if `DISPLAY` is empty or `start-mt5.sh --x11` refuses to run.
- Confirm the operator workstation has a working X server before retrying.
- Do not work around X11 issues by enabling VNC, RDP, reverse proxies, or public GUI ports.
### MT5 window does not appear
- Run `/trading/forex-mt5/scripts/status-mt5.sh` and confirm whether MT5 is actually running.
- Review `/trading/forex-mt5/logs/mt5-run.log`.
- Review `/trading/forex-mt5/scripts/review-latest-logs.sh --lines 40`.
- Stop MT5 cleanly before retrying with `/trading/forex-mt5/scripts/stop-mt5.sh`.
### Demo login failed
- Confirm the selected broker server is a demo server, not a live server.
- Re-check login ID, password, and server name inside MT5 before retrying.
- Review `Journal` plus `/trading/forex-mt5/scripts/logs-mt5.sh 80` for authentication or connectivity errors.
### Chart is empty
- Confirm the bottom-right connection indicator is active and `Market Watch` shows symbols.
- Use `Market Watch -> Show All`, then open a fresh `EURUSD` chart.
- If quotes stay empty and `Journal` shows disconnect or no-price errors, stop and review logs before retrying.
### Journal shows errors
- Stop the session if errors repeat, MT5 starts spamming logs, or the terminal becomes sluggish.
- Review `/trading/forex-mt5/scripts/review-latest-logs.sh --lines 60`.
- Preserve the current prefix state before any deeper repair work.
## Basic Recovery
1. Run `/trading/forex-mt5/scripts/stop-mt5.sh`.
2. Run `/trading/shared/scripts/permissions-audit.sh`.
3. Review `/trading/forex-mt5/logs/mt5-run.log`.
4. Review the UTF-16 terminal logs via `/trading/forex-mt5/scripts/logs-mt5.sh`.
5. If the prefix appears corrupted, preserve it first and then rebuild only under `/trading/forex-mt5`.
## Known Risk
MT5 started successfully on the current host, but the platform log reports Wine `8.0` as unsupported and recommends Wine `10.0+`. This was documented, but no global Wine upgrade was attempted on the production host.