Skip to content
All library documents

Rule-Based Bullish and Bearish Flag Detection with ATR Filters

Article MQL5 articles

Summary

This article describes an MQL5 chart indicator that detects bullish and bearish flag formations using explicit structural rules. It validates an impulsive pole relative to ATR, limits consolidation retracement as a percentage of the pole, constrains flag duration, and checks consolidation behavior and breakout direction. Detected structures are drawn as chart objects, including the pole, a slanted channel, a shaded consolidation region, breakout markers, and labels. Optional alerts and duplicate or overlap controls support ongoing chart monitoring.

The approach treats a flag as a pause after directional expansion, with a controlled countertrend or sideways phase and a continuation breakout. Its configurable thresholds make visual pattern judgments more reproducible, but the document presents an implementation rather than evidence of predictive performance. It gives no measured hit rate, return profile, transaction-cost analysis, or comparison with a baseline. ATR normalization and retracement limits can filter candidate structures, but their suitability may vary across instruments, timeframes, and market regimes.

Key ideas

  • A flag detector can formalize pole strength, retracement depth, consolidation duration, and breakout confirmation.
  • ATR multiples scale the minimum pole threshold to recent volatility.
  • Bullish flags follow upward impulses and bearish flags follow downward impulses, with consolidation against or sideways to the move.
  • Chart objects and optional alerts make identified patterns visible as they form or confirm.
  • Rule-based detection improves consistency of classification but does not establish profitability or predictive accuracy.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.