Donchian Flag Pole Detector

Donchian Flag Pole Detector

Description

The Donchian Flag Pole Detector indicator identifies potential bullish and bearish flag patterns by analyzing price movements in relation to the Donchian Channel. Unlike traditional consolidation-based flags, this indicator accommodates patterns where price trends in one direction during a load phase before sharply reversing in a flag pole phase. This reversal-based approach captures patterns with strong directional shifts, signaling increased momentum and potential trend continuation.

Traders can adjust key parameters like the Donchian Channel period and the load phase length to refine the detection sensitivity. A crucial component of this indicator is that the average body size of bars within the flag pole phase must exceed that observed during the load phase. This condition highlights patterns where the shift in momentum is significant enough to suggest potential breakout opportunities.

Key Features:

  • Reversal-Based Flag Detection: Detects patterns where the load phase trends in one direction, followed by a reversal-driven flag pole, identifying strong directional shifts.
  • Customizable Detection Settings: Parameters like the Donchian Channel period and load phase length allow fine-tuning to suit various market conditions.
  • Average Body Size Ratio: Ensures that the average body size of bars in the flag pole exceeds that of the load phase, prioritizing patterns with substantial momentum.
  • Visual Signals: Plots triangles for bullish and bearish flag poles, with hash markers outlining the flag’s range, giving traders clear visual references for potential entry levels.

Tips for Implementation:

  • Strategic Confirmation: Use the detected flag boundaries as dynamic support/resistance to confirm entries, and complement signals with indicators like MACD or RSI.
  • Parameter Calibration: Adjust the Donchian Channel period and load period based on volatility, and modify the AverageBodySizeRatio to fine-tune the threshold for body size.
  • Backtesting: Run extensive backtests across different market conditions to confirm optimal settings for consistent flag detection.
  • Reversal Opportunity Setup: Incorporate this indicator into reversal or trend-following strategies, using detected flags as potential entry points for trend continuation or reversal setups.

Parameters

DonchianChannelPeriod

  • Type: int
  • Description: The period for calculating the Donchian Channel, defining the high and low boundaries that frame the flag pattern.
  • Default Value: 5
  • Valid Values: Any integer greater than or equal to 1

LoadPeriod

  • Type: int
  • Description: Sets the number of bars for the load phase, where price trends before a momentum shift.
  • Default Value: 2
  • Valid Values: Any integer greater than or equal to 1

BodyAveragePeriod

  • Type: int
  • Description: Number of bars used to calculate the average body size during the load phase, establishing a baseline for momentum comparison.
  • Default Value: 3
  • Valid Values: Any integer greater than or equal to 1

PoleMinBars

  • Type: int
  • Description: Minimum bar count required for a valid flag pole.
  • Default Value: 1
  • Valid Values: Any integer greater than or equal to 1

PoleMaxBars

  • Type: int
  • Description: Maximum number of bars allowed within a flag pole.
  • Default Value: 1
  • Valid Values: Any integer greater than or equal to 1

AverageBodySizeRatio

  • Type: double
  • Description: Minimum required ratio between the average body size of flag pole bars and load phase bars, ensuring significant momentum.
  • Default Value: 1.5
  • Valid Values: Any non-negative double

PlotOffset

  • Type: int
  • Description: Sets the distance in ticks between the signal plot and the high/low of the bar, enhancing clarity.
  • Default Value: 5
  • Valid Values: Any integer greater than or equal to 1

Plots

ndicatorSignalUp

  • Type: Plot
  • Style: Triangle Up
  • Color: Green
  • Description: Marks the presence of a bullish flag pole pattern, serving as a potential entry signal for upward momentum.

SignalUpUpperLevel

  • Type: Plot
  • Style: Hash
  • Color: Green
  • Description: Displays the upper boundary of the bullish flag pattern, indicating a potential breakout level.

SignalUpLowerLevel

  • Type: Plot
  • Style: Hash
  • Color: Green
  • Description: Shows the lower boundary of the bullish flag, providing support within the pattern.

IndicatorSignalDown

  • Type: Plot
  • Style: Triangle Down
  • Color: Red
  • Description: Indicates a bearish flag pole pattern, highlighting potential for downward continuation.

SignalDownUpperLevel

  • Type: Plot
  • Style: Hash
  • Color: Red
  • Description: Marks the upper boundary of the bearish flag, serving as a potential resistance level.

SignalDownLowerLevel

  • Type: Plot
  • Style: Hash
  • Color: Red
  • Description: Displays the lower boundary of the bearish flag pattern, suggesting potential breakout support.