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 11): Fractal Features in Python.
The article examines a Williams five‑bar fractal feature pipeline and shows how a centered rolling window creates a true look‑ahead leak. It identifies two additional silent bugs—a hardcoded shift tied to the default n and a volatility threshold that ignores its input—and consolidates fixes under a single leak_safe flag. Readers get leak‑free fractal, level, trend, and signal features, plus guidance on when unshifted columns remain valid for labeling.
Williams' fractal is a minimal definition of a turning point: a high is a bearish fractal if it exceeds the two highs on each side of it; a low is a bullish fractal if it is exceeded by the two lows on each side of it (Williams, 1998). It requires no parameters beyond the number of confirming bars, n, on each side — the classic setting is n=2, giving a five-bar window. Because the condition is purely structural (a local extremum test), it says nothing about magnitude or duration; a fractal on a 1-minute chart and a fractal on a monthly chart are the same pattern at different scales.
That scale invariance is the link to Mandelbrot's argument that markets are self-similar across timeframes and that price series carry long memory that a random-walk model does not capture (Mandelbrot, 2004). This is also why a fractal detector is attractive for ML feature generation: with the same n, it produces a comparable signal whether it runs on tick bars, minute bars, or daily bars. That consistency matters when features from multiple bar types feed the same model, and it pairs naturally with the alternative bar constructions covered in earlier MQL5 Machine Learning Blueprint articles.
The practical value of a confirmed fractal is as a reference level: the market has already demonstrated that it rejected moves beyond that level once, so a return to the same level is a natural place to look for a repeat rejection (support/resistance) or a break of structure. The fractals module turns that single structural test into eight downstream feature groups: strength, validation, distance to support and resistance, breakout flags, trend strength, trend direction, and a filtered buy/sell signal with a magnitude score.
Pipeline Architecture
Author: Patrick Murimi Njoroge