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
Check out the new article: Feature Engineering for ML (Part 10): Structural Break Tests in MQL5.
We port AFML Chapter 17 structural break tests to MQL5 as a single include, CStructuralBreaks, delivering six bar-indexed features for EAs: CSW statistic and critical value, Chow-Type DFC, SADF with a rolling lookback (default 252), SM-Exp, and SM-Power. SADF uses O(L²) rolling windows for real-time viability. A companion StructuralBreaksViewer indicator plots all series with per‑series visibility and optional z‑score normalization. SB_EMPTY marks invalid values for safe integration.
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.
Author: Patrick Murimi Njoroge