360 Secure SkillHub
360 安全技能中心

ea-upload-opsaetning

面向 MetaTrader 5 的标准化 EA 部署流程:复制 .mq5/.mqh 源码到 MT5 目录,用 Wine 运行 MetaEditor64 编译,重启 mt5.service,再通过日志与心跳文件验证 EA 是否运行。附常见错误提示、手动回退命令与部署后核对清单。

分类:自动化
mohamedabdisamed
mohamedabdisamed
热度 3.07
最近更新 2026-08-20 17:43:31

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add mohamedabdisamed/ea-upload-opsaetning
兼容性
OpenClaw 专属
联网要求
需要联网
数据出网
数据不出本机
Metadata
name
ea-upload-opsaetning
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"]}}}

EA Upload & Setup (DRT-Axe on MT5/Vantage) 🪓

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 /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)

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:
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