Multi-Threaded Trading Robot with Machine Learning (MQL5, 2026-07-23)
yevgeniy-koshtenko‘s build log for a hybrid Python + MetaTrader 5 robot trading five FX pairs (EURUSD, GBPUSD, AUDUSD, NZDUSD, USDCAD) at once off an XGBoost classifier, with a portfolio-level risk budget over the whole book. Part 1 of a series; MQL5 porting, GUI, risk management and cloud training are promised later.
Concurrency by leaving the platform
MQL5 runs an EA single-threaded, so the article doesn’t parallelize MQL5 at all — it moves the
computation into Python threads, one per symbol via a process_symbol function, and leaves
MetaTrader as the order-execution endpoint reached through its Python API. Python is the brain, MT5 is
the hands. That’s a general pattern worth naming: when the trading platform’s execution model is the
constraint, the strategy layer emigrates and the platform is demoted to a broker connector.
The author is clear about the cost: the hybrid has “fundamental speed constraints,” and he estimates a full MQL5 port would run 10–50× faster.
The model stack
Prediction is a classification problem — buy/sell signal, not a price forecast, which distinguishes it from Kronos-style forecasting:
- Features from RSI, MACD, ATR, Williams %R and the Aroon Oscillator, plus synthetic features built from random mathematical combinations of them
- Recursive Feature Elimination down to ~15 features
- Gaussian Mixture Models to cluster market regimes
- XGBoost under a BaggingClassifier — ensembling at two levels — tuned by GridSearchCV
- Labels come from simulated trades with a 300-point stop and 800-point target
- Position sizing from ATR volatility against a TOTAL_PORTFOLIO_RISK budget (USD 500 spread across instruments)
Two details stand out. The regularization is extreme — subsample=0.01, colsample_bytree=0.1, i.e.
each tree sees 1% of rows and 10% of columns — which is the shape you reach for when overfitting is
the thing you’re most afraid of. And the training set is augmented: noise, time-shifting, scaling
and inversion expand ~1,000 hours of history into ~5,000 examples (synthetic-market-data).
The result, and the author’s own caveat
Reported test accuracy is 64–65%, average profit above average loss, with an encouraging simulated profit curve. Then he undercuts it himself: “I do not really trust homemade Python testers,” saying he’d rather see the MQL5 Strategy Tester run against real tick data. There is no live validation — simulation and forward testing only.
That admission is why this source earns its place despite being T3 author-published like the rest of the corpus. It’s the first source here where the author names the evaluation weakness the spoke’s standing open question is about, rather than reporting a number and stopping.
Stated limitations (his list, not mine)
Speed of the Python/MT5 hybrid; data scarcity (he proposes GANs generating 25 years of synthetic history); one ensemble where he’d rather have ~100 regime-specialized models; local compute as a training bottleneck (proposing GCP); and no live trading yet.
Related
supervised-learning-trading · synthetic-market-data · backtesting · market-regime-analysis · algorithmic-trading · yevgeniy-koshtenko