Leak-Safe Fractal Features for Machine Learning in MQL5
Summary
The article ports a Python fractal feature set into an event-driven MQL5 engine while preserving causal timing. A fractal centered on bar c requires n later bars for confirmation, so the feature values are published at the confirmation bar and refer back to the earlier center. Chart markers may still be placed on that center, but feature buffers must not expose the value there. The engine computes high and low fractals, their strength relative to a window mean, threshold-based validity, support and resistance from recent confirmed fractal events, breakout flags, and trend-related measures.
Internal event and breakout rings preserve state for incremental bar processing, while a full-series method resets and recomputes the same outputs. The article reports close agreement with its Python reference across five parameter sets and eighteen feature columns, with maximum deviation of 1.1e-13. That verifies implementation parity, not predictive value: the author explicitly leaves signal quality to later feature-importance work. Threshold selection, event-based lookback semantics, and treatment of repeated extrema also affect interpretation.
Key ideas
- A centered fractal is only confirmed after the required bars to its right have closed.
- Feature buffers publish values at confirmation time, while display markers can identify the earlier extremum.
- Support and resistance lookbacks count confirmed fractal events rather than ordinary bars.
- The engine combines fractal strength, validity, breakout, level, and trend features in a stateful bar-by-bar process.
- Numerical agreement with Python verifies parity, but does not show that the features predict returns.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.