OPEN-SOURCE SCRIPT

GBPUSD Breakout Scanner

413
This indicator is designed for GBPUSD traders on the H1 timeframe who want an objective, real-time filter for distinguishing trending market conditions from ranging ones before acting on a structure breakout signal.


What it does

The scanner detects when price closes above a recent swing high (bullish breakout) or below a recent swing low (bearish breakout), but only surfaces a signal when three independent momentum gates are simultaneously satisfied. If any gate fails, the signal is suppressed and no label appears on the chart.


The three hard gates

Gate 1 — ADX (Average Directional Index)
ADX measures the strength of a directional trend, regardless of whether the trend is up or down. When ADX falls below the user-defined minimum (default: 20), the market lacks directional conviction and all signals are blocked. This prevents entries during sustained low-momentum sideways conditions.

Gate 2 — ATR Compression Ratio
The Average True Range is compared against its own 50-bar simple moving average to produce a ratio. A ratio below the threshold (default: 0.70) indicates that current volatility has compressed relative to its recent history — a common characteristic of range-bound price action. When the ratio is too low, signals are blocked.

Gate 3 — Bollinger Band Width Percentile (self-calibrating)
Rather than using a fixed absolute BBW threshold (which would not adapt to changing volatility regimes), this gate calculates where the current BBW sits as a percentile within its own 50-bar high/low range. A reading of 0% means the bands are at their tightest in 50 bars; 100% means fully expanded. When the percentile falls below the threshold (default: 30%), the market is considered to be in a squeeze and signals are blocked. This approach self-calibrates to the instrument's current behaviour without requiring manual adjustment.

Direction detection

The indicator also surfaces the directional lean of the market using the DI+ and DI− components already computed as part of the ADX/DMI calculation. When DI+ exceeds DI−, the panel shows BULLISH; when DI− leads, it shows BEARISH. This gives traders a clear read on which way momentum is leaning at the time a breakout fires.

Bottom-right status panel

A persistent panel in the bottom-right corner shows live readings for all three gates plus the direction:
- ADX value — green if passing (≥ 20), red if blocking
- ATR Ratio — green if passing (≥ 0.70), red if compressed
- BBW Percentile — green if passing (≥ 30%), red if in squeeze
- MARKET — TRENDING (green) or RANGING (red) summary
- DIRECTION — BULLISH or BEARISH with raw DI+/DI− values
This panel is visible at all times regardless of whether a signal has fired, allowing traders to assess market conditions continuously throughout a session.

Signal labels

When all three gates pass and a structure breakout is detected, a label appears:
- BREAKOUT UP — plotted below the candle for a bullish breakout
- BREAKOUT DOWN — plotted above the candle for a bearish breakout

Each label shows the confirming ADX, ATR and BBW values at the moment of the signal so traders can evaluate the quality of the market conditions that produced it.

Swing highs and lows used for breakout detection are marked with small triangle shapes on the chart.

Important notes

This indicator does not repaint. Breakout signals are based on the closing price of the confirmed bar and do not change after the bar closes.

Swing high/low detection uses TradingView's pivothigh() and pivotlow() functions, which require a lookback period on both sides of the pivot to confirm. This means pivot markers appear a few bars after the actual pivot forms — this is expected behaviour and is not a bug.

This script is designed for use on GBPUSD, H1. Results on other instruments or timeframes have not been validated and may differ significantly.

No signal produced by this indicator constitutes financial advice. Past performance does not guarantee future results. Always use sound risk management.

Adjustable inputs

- Swing pivot length (default: 3)
- ADX length and minimum threshold (default: 14 / 20)
- ATR length, MA length, and minimum ratio (default: 14 / 50 / 0.70)
- Bollinger Band length, standard deviation, lookback and squeeze threshold (default: 20 / 2.0 / 50 bars / 30%)

Published open-source. No external libraries used. Written in Pine Script v6.

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.