Rule-Based Bull and Bear Flag Detection with Breakout Signals
Summary
This indicator defines bull flags as pauses after a qualifying upward move and bear flags as pauses after a qualifying decline. It tracks candidate highs and lows, measures the pullback or rally within each flag, counts its duration, and checks whether the preceding move meets configurable size and length requirements. Separate settings control the allowed flag depth or rally, minimum and maximum flag duration, and the qualifying pole.
When the conditions align, the script draws the flag boundaries and pole on the chart, can mark an upward breakout or downward breakdown, and provides alert conditions for detected patterns and breakouts. The criteria are parameterized heuristics; the document supplies no backtest results or evidence that the signals predict profitable moves. Its signals depend on bar highs, lows, closes, and user-selected thresholds, so detection may vary with timeframe and settings. The code is best read as a concrete pattern-identification rule set, not as a validated standalone trading system.
Key ideas
- The indicator identifies candidate flags by tracking a local extreme and the counter-move that follows it.
- Bull and bear patterns have separate thresholds for pole size, flag duration, and counter-move depth.
- A bull breakout is triggered when price moves above the candidate flag high after the minimum flag duration.
- A bear breakdown is triggered when price moves below the candidate flag low after its duration requirement.
- The script plots pattern lines and offers alert conditions, but provides no performance validation.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.