AlgoAlpha
TradingView IndicatorFree to Use

Flag Breakout Forecasts

Free TradingView Indicator by AlgoAlpha — Volume & Order Flow

This indicator detects converging price channels — commonly called flags or wedges — directly on the chart using a zigzag-based pivot detection algorithm. It identifies three collinear pivot points on both the highs and the lows to confirm a valid channel, then monitors the channel in real time for a breakout.

11.1kviews
1.1kboosts
2026-03-20published

What is Flag Breakout Forecasts?

This indicator detects converging price channels — commonly called flags or wedges — directly on the chart using a zigzag-based pivot detection algorithm. It identifies three collinear pivot points on both the highs and the lows to confirm a valid channel, then monitors the channel in real time for a breakout.

Beyond just drawing the channel, the script assigns probabilistic forecasts to each active pattern. It uses the historical distribution of past breakout durations and directions to estimate the likelihood of an imminent breakout, whether that breakout will be bullish or bearish, and adjusts those estimates using live volume data accumulated inside the pattern.

A supplemental volume table and a net-volume gauge render alongside each detected pattern, giving traders a second lens into the supply-and-demand balance before a move resolves.

Flag Breakout Forecasts Features

Automatic channel detection

Channels are drawn the moment three collinear pivots are confirmed on each side with matching alignment and convergence.

Solid lines for fully confirmed channels.

Dashed lines for the side that is still waiting on a third confirmed pivot.

Probabilistic overlay label

Displayed above each active channel.

P(break)

probability that a breakout will occur soon, based on how the current pattern duration compares to historical durations.

P(bull) / P(bear)

directional probabilities derived from historical breakout directions and blended with live net volume.

Net volume gauge

A color-gradient vertical bar drawn to the right of the last candle, with a pointer showing whether up-close or down-close volume dominates the current pattern.

Volume statistics table

Shows bullish volume, bearish volume, net volume, total volume, ATR, and pattern duration for the most recent active pattern. Cell background intensity scales with volume magnitude.

Breakout signals

Arrow labels mark the breakout bar with the direction, total volume absorbed, and the number of bars the pattern lasted.

Background highlight

A subtle background color appears on the bar when a new pattern is first detected. To help users know the exact time the pattern was detected

How Flag Breakout Forecasts Works

Zigzag — A filtered sequence of alternating swing highs and swing lows. Pivots are confirmed only after a user defined bars on each side, so shorter user defined values capture minor swings and larger values require more significant price moves. Collinearity check — Given three pivot points, the script projects a straight line from the first to the third and measures how far the middle pivot deviates from it, expressed as a percentage of price. If the deviation falls below the tolerance threshold, the three pivots are treated as lying on the same trendline. Converging channel — A pair of trendlines (one through swing highs, one through swing lows) where the gap between them narrows from left to right. This geometry distinguishes flags and symmetric wedges from parallel channels. Early detection — When one trendline is confirmed but the other lacks a third pivot, the script uses the current running extreme (an unconfirmed potential pivot) as a temporary third point. The resulting line is drawn dashed and upgrades to solid when the pivot is confirmed. Breakout confirmation — A break is logged after the close exits the projected channel boundary for two consecutive bars, or immediately when the breakout candle body extends well beyond the boundary and its body size is at least 3 standard deviations above the 20-bar mean body length. Normal CDF approximation — Breakout duration probabilities are derived using the Abramowitz and Stegun rational approximation to the standard normal cumulative distribution function, applied to z-scores computed from the historical distribution of past breakout durations. Net volume ratio — Bullish volume (up-close bars) minus bearish volume (down-close bars), divided by total volume, mapped to a −100 to +100 scale. Used to tilt the directional probability estimate away from the purely historical base rate.

How to Use Flag Breakout Forecasts

Adjust len to match the swings you trade — lower values (3–5) for intraday patterns, higher values (10–20) for swing or position setups. Tighten collinearity tolerance to 0.1–0.2% if you want only very clean trendline alignments; loosen it toward 1% if you want the indicator to catch more approximate formations. Watch the dashed channel side — it signals an early, unconfirmed pattern. Treat it as a warning rather than a confirmed setup, and wait for it to turn solid before acting. Check P(break) in the label — a reading above 70% means the current pattern has already lasted longer than most historical patterns, suggesting a resolution is statistically overdue. Use P(bull) and P(bear) alongside the volume gauge — when P(bull) is elevated and the gauge leans bullish, the two signals agree on direction. Disagreement between them calls for extra caution. Reference the volume table's net row — persistently positive net volume during a bearish-looking wedge can indicate absorption of selling pressure and a possible upside resolution. Set alerts for "Pattern formed," "Bullish breakout," "Bearish breakout," and the strong-break variants to monitor multiple instruments without watching the chart continuously.

Free on TradingView

Add this indicator to your chart.

Flag Breakout Forecasts is free to use on TradingView. Add it to any chart in seconds.