Discussing the article: "Meta-Labeling the Classics (Part 3): Filtering and Sizing Bollinger Band Trades"

 

Check out the new article: Meta-Labeling the Classics (Part 3): Filtering and Sizing Bollinger Band Trades.

Bollinger Band mean reversion degrades in trending regimes when ADX is high and bandwidth expands. We separate direction from trade selection with a two‑stage meta‑labeling pipeline: a gradient‑boosted secondary classifier trained with PurgedKFold on band‑specific features (BBP, BBB, bandwidth regime) outputs action probabilities that drive probability‑based bet sizing. The MQL5 implementation loads the ONNX model and applies position sizing within a two‑EA architecture to filter low‑quality band touches.

A Bollinger Band mean-reversion strategy fires when price touches the upper or lower band and assumes price will return to the moving average. The assumption holds in ranging markets. It fails in trending markets, and the failure is not random: it is systematic. When ADX is above 25 and bandwidth is expanding, the band touch is more likely to be the start of a breakout than a reversion opportunity. The primary model cannot know this because it applies the same rule in all regimes. The consequence is a predictable cluster of losses at the precise moments when a trend is establishing itself.

The meta-labeling framework, introduced by Marcos López de Prado in Chapter 3 of Advances in Financial Machine Learning, addresses this class of problem directly. It separates two questions that the primary model conflates: in which direction should we trade, and should we trade at all? The primary model answers the first question. A secondary binary classifier answers the second. When the secondary model outputs a probability, it also determines position size. High-confidence cases receive full allocation; marginal cases receive a fraction. Bet sizing uses the same probability-to-signal mapping developed in Part 10 of the Machine Learning Blueprint for MetaTrader 5 series.

This article is the third in the Meta-Labeling the Classics series. Part 1 applied the framework to RSI, which is a momentum oscillator with a uniform [0, 100] scale. Part 2 did the same for ADX, which is a trend-strength indicator. Bollinger Bands add a dimension that RSI lacks: bandwidth. It measures whether the current market environment is consistent with the signal's mean‑reversion assumption. That self-diagnostic property makes Bollinger Bands a more tractable candidate for meta-labeling — and means the secondary model's feature engineering is qualitatively different from the RSI case.

The implementation follows the two-stage ModelDevelopmentPipeline workflow established in Blueprint Part 9. It reuses BollingerStrategy and adds create_bollinger_features for Bollinger-specific features. Deployment uses the two‑EA file‑bus architecture adapted for ONNX inference.

Bollinger Band signal quality by market regime

Author: Patrick Murimi Njoroge