Articles

Feature Engineering for ML (Part 3): Session-Aware Time Features for Forex Machine Learning for MetaTrader 5

The article addresses the loss of temporal information in ML pipelines by encoding periodic time variables with Fourier harmonics and adding forex session structure. It implements session and overlap flags, lagged session volatility, and calendar effects, then prunes features by timeframe. The get

MetaTrader 5 Machine Learning Blueprint (Part 15): How to Calibrate Profit-Taking and Stop-Loss Targets from Synthetic Data for MetaTrader 5

This article applies the Optimal Trading Rule from AFML Chapter 13 to set profit targets and stop-losses without in-sample calibration. We model post-entry P&L with a discrete Ornstein–Uhlenbeck process, run a 100,000-path search, and implement Python, multiprocessing, and a Numba @njit parallel

MetaTrader 5 Machine Learning Blueprint (Part 14): Transaction Cost Modeling for Triple-Barrier Labels in MQL5 for MetaTrader 5

The article replaces hardcoded cost assumptions in triple-barrier labeling with measured inputs. An MQL5 script captures spread distribution, swap rates, and symbol metadata from your broker, and a Python model converts them into a broker-calibrated min ret you can pass to get events. Labels then

Beyond the Clock (Part 1): Building Activity and Imbalance Bars in Python and MQL5 for MetaTrader 5

The article replaces clock-based sampling with López de Prado's alternative bar types and provides two aligned implementations: a unified Python module for batch tick histories and an object‑oriented MQL5 library for live EAs. It covers Parquet/Dask infrastructure, data cleaning, and a single API

Feature Engineering for ML (Part 2): Implementing Fixed-Width Fractional Differentiation in MQL5 for MetaTrader 5

This article delivers a production-grade MQL5 implementation of fixed-width fractional differentiation for live MetaTrader 5 feeds. We introduce a header-only CFFDEngine that precomputes weights without a fixed cap, performs O(width) per-bar updates, and avoids per-tick allocations. The FFD.mq5

MetaTrader 5 Machine Learning Blueprint (Part 13): Implementing Bet Sizing in MQL5 for MetaTrader 5

We build a production MQL5 bet‑sizing toolkit: utilities, snippets, and user‑level functions that mirror the Python originals. The methods cover probability‑to‑size mapping with overlap correction, dynamic forecast‑price sizing (calibrated sigmoid/power with limit price), occupancy‑based budgeting

Feature Engineering for ML (Part 1): Fractional Differentiation — Stationarity Without Memory Loss for MetaTrader 5

Integer differentiation forces a binary choice between stationarity and memory: returns (d=1) are stationary but discard all price-level information; raw prices (d=0) preserve memory but violate ML stationarity assumptions. We implement the fixed-width fractional differentiation (FFD) method from

MetaTrader 5 Machine Learning Blueprint (Part 12): Probability Calibration for Financial Machine Learning for MetaTrader 5

Tree-based classifiers are typically overconfident: true win rates near 0.55 appear as 0.65–0.80 and inflate position sizes and Kelly fractions. This article presents afml.calibration and CalibratorCV, which generate out-of-fold predictions via PurgedKFold and fit isotonic regression or Platt

MetaTrader 5 Machine Learning Blueprint (Part 11): Kelly Criterion, Prop Firm Integration, and CPCV Dynamic Backtesting for MetaTrader 5

The bet-sizing signal from Part 10 is concurrency-corrected but carries no payoff-ratio adjustment, no response to a hard drawdown budget, and no validation across combinatorial paths. This article covers three additions: a two-stage architecture in which a Kelly payoff multiplier is applied on top

MetaTrader 5 Machine Learning Blueprint (Part 10): Bet Sizing for Financial Machine Learning for MetaTrader 5

Fixed fractions and raw probabilities misallocate risk under overlapping labels and induce overtrading. This article delivers four AFML-compliant sizers: probability-based (z-score → CDF, active-bet averaging, discretization), forecast-price (sigmoid/power with w calibration and limit price)