You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Feature Engineering for ML (Part 9): Structural Break Tests in Python
The preceding articles in this Feature Engineering for ML series built features from the structure of time itself: Part 1 established fractional differentiation as a way to preserve long memory in a stationary series; Part 3 embedded the trading calendar into Fourier coordinates; and Part 5 compressed tick-level order flow into bar-indexed microstructural statistics. This article builds features from a qualitatively different question: not what the current bar looks like, but whether the data-generating process that produced it has recently changed.
Feature Engineering for ML (Part 10): Structural Break Tests in MQL5
Part 9 of this series implemented the structural break test suite from AFML Chapter 17 in Python, covering the Chu-Stinchcombe-White CUSUM test, the Chow-Type Dickey-Fuller test, SADF across six regression models, and two robustifying variants (QADF and CADF). This article ports the three core tests — CSW, Chow, and SADF — to MQL5 as a single include file, CStructuralBreaks.mqh, placed in MQL5/Include/StructuralBreaks/. The sub- and super-martingale tests (SM-Exp and SM-Power) are included as well, rounding the suite to five statistics per bar.
The MQL5 implementation departs from the Python version in one structural decision that is worth stating immediately: SADF uses a rolling lookback window rather than a full expanding window. In Python, the expanding window is viable because the computation runs once offline on a fixed dataset. In an EA that recalculates on each new bar, an expanding window scales as O(T²) with the number of completed bars. At T = 1,000 bars — a modest two-year daily series — the expanding window performs 15× more inner-loop operations than a 252-bar rolling window. At T = 5,000 bars it performs 400× more. The rolling window is not a compromise; it changes the interpretation of the statistic slightly, and that change is documented in Section 6.
Feature Engineering for ML (Part 11): Fractal Features in Python
The preceding articles in this Feature Engineering for ML series derived features from price geometry (Part 1), from the trading calendar (Part 3), from the bid-ask spread and price impact (Parts 5–6), from the information content of the trade-direction sequence (Part 7), and, most recently, from the timing of regime changes themselves (Part 10). This eleventh installment returns to price geometry, but at a coarser structural level: the swing highs and swing lows that define support, resistance, and trend.