main
Mad Turtle v2.0 — Improved ML EA for XAUUSD
Modern ML trading system: Python inference server + ONNX models + MQL5 EA with UI.
Architecture
madturtle/
├── python/
│ ├── ml_pipeline/
│ │ └── build_onnx_raw.py # Build demo/train real ONNX models
│ ├── inference_server/
│ │ └── server.py # FastAPI REST server
│ ├── run_server.py # Server launcher
│ └── requirements.txt
├── models/
│ ├── xauusd_h1_ensemble.onnx # ONNX model (demo included)
│ └── metadata.json # Feature schema + model info
└── mql5/
├── scripts/
│ └── MadTurtle.mq5 # Main EA
└── include/
├── MadTurtle_API.mqh # HTTP bridge to Python server
├── MadTurtle_MTF.mqh # Multi-timeframe filters (H4/D1)
└── MadTurtle_UI.mqh # Status dashboard + oscillator + equity curve
Quick Start
1. Python inference server (macOS/Linux)
# Create venv (Python 3.11 or 3.12 recommended for sklearn+skl2onnx)
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install numpy onnx onnxruntime fastapi uvicorn pydantic
# Run server
python python/run_server.py
# Server starts on http://0.0.0.0:8000
Test:
curl http://127.0.0.1:8000/health
2. Train a real ONNX model (optional)
# Requires Python 3.11/3.12 + scikit-learn + skl2onnx
pip install scikit-learn skl2onnx pandas
# With real XAUUSD H1 OHLCV CSV:
python python/ml_pipeline/train_onnx.py
# Or build the current demo model:
python python/ml_pipeline/build_onnx_raw.py
CSV format: datetime,open,high,low,close,volume
3. MQL5 EA setup
- Open MetaTrader 5
- Press
F4→ Open MetaEditor - Create new Expert Advisor
MadTurtle - Replace generated files with:
MadTurtle.mq5→mql5/scripts/MadTurtle_API.mqh,MadTurtle_MTF.mqh,MadTurtle_UI.mqh→mql5/include/
- Compile (
F7)
4. Run
- Attach EA to XAUUSD H1 chart
- Set server host/port in inputs (default
127.0.0.1:8000) - Ensure Python server is running before EA starts
- Configure risk inputs manually (lot size, max positions, confidence threshold)
Features
- Real ML inference via ONNX Runtime (no external API calls at runtime)
- 14 engineered features: returns, SMAs, EMA/MACD, RSI, ATR, volume ratio, range, dist_sma20
- Multi-class output: BUY / HOLD / SELL with confidence probabilities
- Multi-timeframe confirmation (H4 + D1 SMA/RSI/MACD filters)
- Dark-themed UI: status dashboard, P&L metrics, equity curve, signal oscillator, chart arrows
- No grid, no martingale, no external dependencies at runtime
Risk Management
You define all risk parameters in EA inputs:
InpLotSize— fixed lot per tradeInpMaxPositions— max simultaneous positionsInpMinConfidence— minimum model confidence to tradeInpStopLossPts/InpTakeProfitPts— fallback SL/TP if model doesn’t set them
Model Replacement
- Train a new model on real data
- Export to
models/xauusd_h1_ensemble.onnx - Restart Python server — EA picks it up automatically
License
MIT — improved upon Mad Turtle concept. Not affiliated with original author.
Description
Mad Turtle v2.0 - Improved ML EA for XAUUSD H1 with Python inference server and MQL5 EA
Languages
MQL5
61.1%
Python
37.7%
Shell
1.2%