Loading…

Flag And Pennant Detector

A pole is only worth calling a pole if it moved with some conviction, so this indicator screens candidate swing legs on two independent measures: length against a multiple of ATR (so the bar is symbol- and volatility-aware rather than a hardcoded pip or percent figure), and a straight-line efficiency ratio - net move divided by the sum of every bar-to-bar absolute move across the leg - so a leg that travelled the same net distance but chopped back and forth to get there scores lower than one that moved in a straight line, even at identical length and duration. After a qualifying pole, the following bars are watched for a consolidation that gives back only a bounded fraction of the pole. Its shape is read by splitting the consolidation into two halves and comparing each half's own high-low range: a range that shrinks by more than a configured threshold is called a Pennant (the classic converging wedge); a range that stays roughly the same width is called a Flag. A close beyond the consolidation's own most recent boundary extreme, in the pole's direction, is the breakout, and it projects a target the same price distance as the pole itself, measured from the breakout price - the standard published Flag/Pennant target. Being honest about a real simplification: the boundary lines drawn on the chart connect the first-half and second-half range extremes, which is an approximation of a fitted trendline, not a least-squares regression through every touch point. The breakout trigger itself uses the fixed second-half extreme as the level to clear, not a continuously extrapolated slope - a strongly sloped channel can therefore be pierced visually before the trigger fires. This keeps the logic simple and predictable at the cost of not perfectly matching a hand-drawn trendline in every case. Notes and limitations - Only one setup (the most recent qualifying pole) is tracked at a time; a second valid pole forming while one is already pending is not evaluated until the first resolves or expires. - The boundary lines are drawn between two-half range extremes, not a regression fit, and the breakout level is that fixed extreme, not a slope-extrapolated line - see the full description for what this trades off. - ATR-based pole sizing and efficiency scoring reduce but do not eliminate symbol-specific tuning; the defaults are a reasonable starting point, not a universal setting. - This is a structure-identification tool, not a trade signal; the breakout and its projected target are reported, not recommended.

Indicator · MT5 · v1.0 · Free

About Flag And Pennant Detector

Flag And Pennant Detector is an indicator for MetaTrader 5 based on ATR. It draws buy and sell arrows on the chart and can alert you with a pop-up, sound, email or push message. It has 10 settings, such as Swing bars, Atr period and Min pole atr multiple. MQL source code included.

Files in the download: FlagPennantDetector.ex5, FlagPennantDetector.mq5, FlagPennantDetector.txt.

Settings

SettingDefaultWhat it does
Swing bars5Bars each side required to confirm a swing
Atr period14ATR period used to size a qualifying pole
Min pole atr multiple2.5Minimum pole length as a multiple of ATR
Max pole bars20Maximum bars a pole leg may take to form
Min pole efficiency0.55Minimum straight-line efficiency of the pole leg (0-1)
Max flag bars25Maximum bars allowed to form the consolidation
Max retrace percent0.55Max consolidation range as a fraction of the pole
Narrowing threshold0.35Fractional range shrink that qualifies as a Pennant
Max bars to breakout40Bars to wait for breakout before the setup expires
AlertstrueAlert once on breakout

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Breakout · ATR · Buy/Sell Arrows · Alerts · MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria