back
loading skill details...
Standardized EA deployment for MT5: copy, compile, restart, verify. One command to deploy your MetaTrader Expert Advisor and confirm it is running with heartbeat verification.
---
name: "ea-upload-setup"
description: "Standardized EA deployment for MT5: copy, compile, restart, verify. One command to deploy your MetaTrader Expert Advisor and confirm it is running with heartbeat verification."
metadata: {"clawbot": {"requires": {"bins": ["wine", "xdotool"]}, "permissions": {"exec": ["bash", "wine", "xdotool", "cp"], "files": ["/home/openclaw/.wine-mt5/", "/home/openclaw/.openclaw/workspace/tradevault/ea/"], "services": ["mt5.service"], "network": [], "notes": "State-changing: copies files into a LIVE MT5 install, compiles, restarts mt5.service, commits to git. Requires explicit confirmation before running."}}}
---
# EA Upload & Setup (DRT-Axe on MT5/Vantage) ๐ช
> โ ๏ธ **WARNING โ STATE-CHANGING OPERATIONS:** This skill copies files into a LIVE MetaTrader 5 installation, compiles an Expert Advisor, restarts the `mt5.service` system service, and may commit changes to git. It can disrupt a running trading service. **Do NOT run without explicit operator confirmation**, and review `deploy_ea.sh` before first use.
**Purpose:** Standardized EA upload โ compile โ restart โ attach โ verify. Written 19/8 2026 after repeated failures (Boss: "you have made the same mistake several times"). **FOLLOW THIS SKILL โ ALWAYS โ when the EA needs to change.**
## ๐จ The 3 mistakes we HAVE made (learn from them!)
1. **`ArraySetAsSeries` missing** โ CopyRates without `ArraySetAsSeries(rates, true)` returns the array OLDEST-FIRST. The code assumes rates[0]=newest โ reads history backwards โ the scan only finds OLD sweeps (e.g. 13/8) โ the age gate drops EVERYTHING โ 0 trades. **ALWAYS check: after every CopyRates/CopyClose call, `ArraySetAsSeries(arr, true)` must be present (also applies to DRT.mqh's DRT_ICTBias + DRT_DailyBias + SilverBullet scan).**
2. **OCR fumbling instead of DevOps scripts** โ NEVER use xdotool/OCR to find the Algo button manually. Run `mt5-ea-fix.py` (DevOps script) โ and if an EA dialog is open, press `Enter` (OK).
3. **Tokens wasted on code review** โ the change is typically 1-4 lines. Fix โ run deploy โ verify. Do NOT read the whole code first.
## โก Standard procedure (1 command)
```bash
bash /home/openclaw/.openclaw/workspace/tradevault/ea/deploy_ea.sh
```
The script: copies .mqh+.mq5 โ MT5 โ compiles (MetaEditor64 via wine+xvfb) โ restarts mt5.service โ verifies "DRT-Axe started" in the log.
- โ
SUCCESS = "EA RUNNING" + fresh heartbeat
- โ ๏ธ "not confirmed after 5 min" = a dialog is waiting โ `xdotool key Return` (with correct DISPLAY/XAUTHORITY)
- โ compile error = fix the code, run again
## ๐ ๏ธ Manual chain (if deploy fails)
```bash
MT5="/home/openclaw/.wine-mt5/drive_c/Program Files/MetaTrader 5"
EA="/home/openclaw/.openclaw/workspace/tradevault/ea"
# 1) Copy
cp "$EA"/DRT.mqh "$MT5/MQL5/Include/DRT.mqh"
cp "$EA"/SilverBullet.mqh "$MT5/MQL5/Include/SilverBullet.mqh"
cp "$EA"/Risk.mqh "$MT5/MQL5/Include/Risk.mqh"
cp "$EA"/TimeFilter.mqh "$MT5/MQL5/Include/TimeFilter.mqh"
cp "$EA"/News.mqh "$MT5/MQL5/Include/News.mqh"
cp "$EA"/Notify.mqh "$MT5/MQL5/Include/Notify.mqh"
cp "$EA"/AntiFlag.mqh "$MT5/MQL5/Include/AntiFlag.mqh"
cp "$EA"/DRT-Axe.mq5 "$MT5/MQL5/Experts/DRT-Axe.mq5"
# 2) Compile (0 errors = OK)
cd "$MT5/MQL5/Experts"
WINEPREFIX=/home/openclaw/.wine-mt5 WINEDLLOVERRIDES=mscoree,mshtml= HOME=/home/openclaw \
xvfb-run -a wine "$MT5/MetaEditor64.exe" /compile:"DRT-Axe.mq5" /log:"compile_deploy.log" >/dev/null 2>&1
sleep 12
iconv -f UTF-16LE -t UTF-8 compile_deploy.log | grep "Result:"
# 3) Restart + verify
sudo systemctl restart mt5.service
sleep 150 # login ~60s + attach
tail -5 "$MT5/MQL5/Files/DRT-Axe_Log.txt" # should show "DRT-Axe started โ 17 symbols"
```
## ๐ Verification (ALWAYS after deploy)
| Check | Command | OK sign |
|---|---|---|
| EA runs | `grep "started" DRT-Axe_Log.txt \| tail -1` | today's date + "17 symbols" |
| Fresh heartbeat | `stat -c %y DRT-Axe_HB.txt` | < 2 min old |
| Fresh scan | `tail DRT-Axe_Log.txt` | sweeps with TODAY's prices (not 13/8 levels) |
| Algo ON | `mt5-algo-ensure.py` | "EA heartbeat fresh โ Algo is ON" |
## ๐ช If a dialog is waiting (EA properties)
- Symptom: EA loaded but "started" missing / HB frozen
- Fix: find DISPLAY+XAUTHORITY, press Enter:
```bash
export DISPLAY=:99 XAUTHORITY=$(ps aux | grep 'Xvfb :99' | grep -v grep | grep -oE '\-auth [^ ]+' | awk '{print $2}' | head -1)
xdotool key Return
```
## ๐ Fixed paths
- EA code (edit ONLY here): `/home/openclaw/.openclaw/workspace/tradevault/ea/`
- MT5 folder: `/home/openclaw/.wine-mt5/drive_c/Program Files/MetaTrader 5`
- EA log: `$MT5/MQL5/Files/DRT-Axe_Log.txt` (server time GMT+3 = UTC+3)
- Heartbeat: `$MT5/MQL5/Files/DRT-Axe_HB.txt`
- Data for the bot: `$MT5/MQL5/Files/DRT-Axe_Data.json` (written every 60s)
- DevOps scripts: `/home/openclaw/.local/bin/mt5-ea-fix.py`, `mt5-ea-attach.sh`, `mt5-login-helper.sh`, `mt5-algo-ensure.py` (cron every 2 min)
## โฐ Trading windows (entries)
London 09-11 ยท NY open 14:30-17:00 ยท SB PM 19:30-21:00 (CET/Danish time). Night pause 23-08.
**Outside windows = no entries** โ that is by design, not a bug. Expect trades in the NY/PM windows.
## ๐ Rules for EA changes (Boss 19/8)
1. Make the CHANGE (typically a few lines) โ do not read the whole code
2. Run `deploy_ea.sh` โ not manual OCR fumbling
3. Verify with the table above
4. Commit: `git add tradevault/ea/ && git commit -m "EA fix: ..."` (part of the workspace repo)
5. Report briefly: what was changed + proof that it is running
don't have the plugin yet? install it then click "run inline in claude" again.