Smart Breakout Targets [WillyAlgoTrader]📡 Smart Breakout Targets is an overlay indicator that detects volatility squeezes using a dual-engine system (Bollinger Band Width compression + ATR contraction), builds adaptive consolidation range boxes, waits for a confirmed impulse candle to break the range, and then automatically places entry, stop-loss, and three take-profit levels based on the breakout's risk distance — with full trade lifecycle tracking that monitors TP/SL hits and marks the outcome directly on the chart.
The core concept: volatility compression precedes expansion. When price coils into a tight range, a breakout from that range tends to produce a directional move proportional to how compressed the range was. This indicator automates the entire workflow: detect the compression, define the range, confirm the breakout, calculate the targets, track the outcome.
Most breakout indicators on TradingView use a single volatility measure (typically Bollinger Band Width or Keltner Channel squeeze) to detect compression. A single measure can produce false positives — BB Width can narrow during a one-directional drift without true consolidation, or ATR can compress during a holiday session without tradeable structure. This indicator requires both engines to agree: BB Width must be below its threshold AND ATR must be below its compression ratio simultaneously. This dual confirmation eliminates the majority of false squeezes.
🧩 WHY THESE COMPONENTS WORK TOGETHER
A squeeze detector alone tells you volatility is low — but it doesn't give you a range to trade against. A range box alone tells you where support and resistance are — but it doesn't confirm whether the breakout is genuine. An impulse filter alone measures candle quality — but without knowing the range boundaries, it doesn't know what's being broken. And TP/SL levels without range context have no structural anchor.
This indicator connects them into a complete breakout workflow:
BB Width squeeze + ATR compression → Range duration check → Adaptive Donchian range → Resistance/Support zones → Impulse candle confirmation → Filter gate (volume + HTF) → Entry at breakout → SL at opposite boundary + ATR buffer → TP1/TP2/TP3 as R:R multiples → Trade lifecycle tracking → Outcome labeling
The dual squeeze engine defines WHEN compression exists. The minimum squeeze duration confirms the consolidation is established, not momentary. The adaptive Donchian tracks the range boundaries DURING the squeeze (expanding with each new high/low). The impulse filter confirms the breakout candle has sufficient body size relative to ATR. The volume and HTF filters add optional quality gates. And the R:R-based targets anchor to the actual risk distance (entry to opposite range boundary), not to arbitrary ATR multiples.
Removing the dual engine reintroduces single-measure false squeezes. Removing the minimum duration allows momentary vol dips to create ranges. Removing the impulse filter lets weak candles trigger breakouts. Removing the ATR-buffered SL places stops too close to range boundaries. Each component solves a specific failure mode.
🔍 WHAT MAKES IT ORIGINAL
1️⃣ Dual-engine squeeze detection (BB Width + ATR compression).
Two independent volatility measures must agree before a squeeze is confirmed:
Engine 1 — Bollinger Band Width:
bbWidth = (upperBB − lowerBB) / basisBB, where upperBB = SMA(close, len) + mult × stdev(close, len). The BB Width is compared to its own SMA: bbSqueeze = bbWidth < SMA(bbWidth, len) × squeezeThreshold (default 0.6). This detects when the bands are significantly tighter than their recent average.
Engine 2 — ATR Compression:
atrVal = ATR(len/2), atrSma = SMA(ATR, len). Compression = atrVal < atrSma × atrCompressRatio (default 0.75). This detects when absolute volatility (measured by ATR) has contracted below its recent average. The ATR period is half the squeeze length for faster response to volatility changes.
Combined: isSqueeze = bbSqueeze AND atrCompress. Both engines must agree simultaneously. BB Width can narrow during a drift (price moving slowly but directionally) while ATR remains normal — the ATR engine blocks this false squeeze. Conversely, ATR can compress during a holiday while BB Width is normal — the BB engine blocks this. Dual agreement ensures genuine consolidation.
2️⃣ Minimum squeeze duration filter.
A squeeze counter tracks consecutive bars where both engines agree. The range box is only created when the squeeze has lasted at least minSqueezeBars (default 5). This prevents momentary dips in volatility (single-bar BB Width contraction during a large candle, for example) from creating spurious ranges. The counter resets to zero when either engine disagrees.
3️⃣ Adaptive Donchian range boundaries.
When a squeeze begins, the indicator initializes squeezeHigh and squeezeLow from the first bar. On each subsequent bar during the squeeze, the boundaries expand: squeezeHigh = max(squeezeHigh, high), squeezeLow = min(squeezeLow, low). This creates an adaptive Donchian channel that captures the full consolidation range — not just a fixed lookback but the exact range from squeeze start to squeeze end.
If the resulting range exceeds 6× ATR (extreme outlier), it's clamped to 3× ATR above and below the range center. This prevents excessively wide ranges from producing unreachable targets.
The range box also includes a resistance zone (top half-ATR, red-tinted) and a support zone (bottom half-ATR, green-tinted), highlighting the areas where price is most likely to be rejected on a false breakout.
4️⃣ Impulse candle breakout confirmation.
A breakout requires more than just closing beyond the range — the breakout candle must be an impulse candle:
Bullish breakout: close > rangeTop AND close > open AND |close − open| > ATR × impulseMultiplier (default 0.8)
Bearish breakout: close < rangeBottom AND close < open AND |close − open| > ATR × impulseMultiplier
This body size filter ensures the breakout candle has genuine momentum behind it — not a thin wick that barely clips the boundary. The impulse multiplier is configurable: lower values (0.3–0.5) accept weaker candles, higher values (1.0–1.5) require strong conviction bars.
5️⃣ R:R-based TP/SL with ATR-buffered stop.
On breakout, the indicator calculates:
— Entry = close of breakout candle
— Stop Loss = opposite range boundary ± ATR × slBuffer (default 0.5). For a bullish breakout: SL = rangeBottom − ATR × 0.5. The buffer prevents the stop from sitting exactly at the range boundary where it would be clipped by a retest wick.
— Risk distance = |entry − SL|
— TP1 = entry ± risk × tp1RR (default 1.0 = 1:1 R:R)
— TP2 = entry ± risk × tp2RR (default 2.0 = 1:2 R:R)
— TP3 = entry ± risk × tp3RR (default 3.0 = 1:3 R:R)
All levels are drawn as extending lines with price labels, plus linefill zones (red = risk area from entry to SL, green = reward area from entry to TP3).
6️⃣ Trade lifecycle tracking with outcome labels.
After a breakout fires, the indicator actively monitors whether price hits TP1, TP2, TP3, or SL:
TP hit detection: for long trades, high ≥ TPx AND high < TPx (first touch). For short trades, low ≤ TPx AND low > TPx. This ensures each TP is counted exactly once.
Trade close conditions:
— TP3 hit → trade marked as "Win (TP3)" → ✔ label placed on chart → all target lines removed
— SL hit → trade marked as "Loss (SL)" → ✘ label placed on chart → all target lines removed
— New breakout while trade active → previous trade replaced
The dashboard shows: Active / Win (TP3) / Loss (SL) with the last P&L in price units. Close labels include tooltips with full trade details (entry, TP3/SL level, P&L).
7️⃣ Overlap prevention for range boxes.
When enabled (default on), the indicator prevents a new range box from overlapping with an existing one. The squeezeStartBar of a new range must be after the right edge of the most recent existing box. This prevents cluttered, overlapping consolidation zones that would create confusing breakout levels.
8️⃣ Signal strength scoring (0–4).
Each breakout receives a strength score based on how many quality factors are present:
— +1 for impulse candle (always true on breakout, baseline)
— +1 for volume surge (if volume filter enabled and passed)
— +1 for HTF alignment (if HTF filter enabled and aligned)
— +1 for extended squeeze (squeeze duration ≥ 2× minimum)
Classification: Strong (≥3), Medium (≥2), Normal (<2). Displayed in the dashboard.
⚙️ HOW IT WORKS — CALCULATION FLOW
Step 1 — Volatility measurement: BB Width = (upperBB − lowerBB) / basis. ATR computed with period = squeezeLenght / 2. Both compared to their SMAs.
Step 2 — Squeeze detection: isSqueeze = (bbWidth < bbWidthSMA × threshold) AND (ATR < atrSMA × compressionRatio). Counter tracks consecutive squeeze bars.
Step 3 — Range construction: When squeeze starts, init boundaries from first bar's high/low. Each bar during squeeze: boundaries expand to include new highs/lows. Range capped at 6× ATR.
Step 4 — Range box creation: When squeeze ends (isSqueeze transitions from true to false) AND duration ≥ minimum bars AND not overlapping → create range box with resistance/support zones and centerline.
Step 5 — Breakout scan: On each confirmed bar, iterate through existing range boxes. If close > rangeTop with bullish impulse + filter pass → bullish breakout. If close < rangeBottom with bearish impulse + filter pass → bearish breakout. The broken range box is removed.
Step 6 — Target placement: Entry = close. SL = opposite boundary ± ATR buffer. TP1/TP2/TP3 = entry ± risk × R:R multipliers. Lines, labels, and fill zones are drawn.
Step 7 — Trade monitoring: Each bar, check if price touched TP1/TP2/TP3 or SL (first-touch detection using current vs previous bar comparison). On TP3 or SL → close trade, label outcome, remove visuals.
📖 HOW TO USE
🎯 Quick start:
1. Add the indicator — gray range boxes appear at detected consolidation zones
2. Red-tinted zone at top = resistance, green-tinted at bottom = support
3. When price breaks out with an impulse candle → "Long" or "Short" label appears
4. Entry, SL, TP1, TP2, TP3 lines are automatically drawn
5. When price reaches TP3 → ✔ label. When SL hit → ✘ label. Trade auto-closes.
👁️ Reading the chart:
— ⬜ Gray box = consolidation range (detected squeeze zone)
— 🟥 Red-tinted top zone = resistance area within range
— 🟩 Green-tinted bottom zone = support area within range
— ➖ Dashed centerline = range midpoint
— 🟢 "Long" label below bar = confirmed bullish breakout
— 🔴 "Short" label above bar = confirmed bearish breakout
— Green solid line = entry price
— Red dashed line = stop loss
— Green dotted lines = TP1, TP2, TP3 levels
— 🟩 Green fill = reward zone (entry to TP3)
— 🟥 Red fill = risk zone (entry to SL)
— ✔ TP3 label = trade closed at target (win)
— ✘ SL label = trade stopped out (loss)
— 🟡 Yellow background (optional) = active squeeze
📊 Dashboard fields:
— Status: Active / Win (TP3) / Loss (SL)
— Signal: last breakout direction with bars elapsed
— Strength: signal quality (Strong / Medium / Normal)
— Trend: current trade direction
— Squeeze: active status with bar count
— Entry / Stop Loss: current trade levels
— Last P&L: profit/loss of last completed trade
— HTF Bias: higher-timeframe trend direction
— Version / TF
🔧 Tuning guide:
— Too many false squeezes: decrease Squeeze Threshold (0.4–0.5), decrease ATR Compression Ratio (0.6–0.7), increase Min Squeeze Bars (8–12)
— Missing squeezes: increase Squeeze Threshold (0.7–0.8), increase ATR Compression Ratio (0.8–0.9), decrease Min Squeeze Bars (3–4)
— Breakouts too weak: increase Impulse Body Threshold (1.0–1.5), enable Volume Filter
— Stops too tight: increase SL ATR Buffer (0.7–1.0)
— Want only trend-aligned breakouts: enable HTF Trend Filter
— Scalping 1–5M: Squeeze Length 15, Min Squeeze 3, Impulse 0.5, TP1 0.75
— Swing 4H–1D: Squeeze Length 30, Min Squeeze 8, Impulse 1.0, TP3 5.0
⚙️ KEY SETTINGS REFERENCE
⚙️ Main:
— Squeeze Detection Length (default 20): lookback for BB Width and ATR baseline
— BB Multiplier (default 2.0): standard deviation multiplier for Bollinger Bands
— Squeeze Threshold (default 0.6): BB Width must be below this fraction of its SMA
— ATR Compression Ratio (default 0.75): ATR must be below this fraction of its SMA
— Min Squeeze Bars (default 5): minimum consecutive squeeze bars for valid range
— Impulse Body Threshold (default 0.8): breakout candle body ≥ ATR × this value
— Prevent Overlap (default On): no overlapping range boxes
🎯 Targets:
— SL ATR Buffer (default 0.5): extra ATR distance beyond range boundary for stop
— TP1 R:R (default 1.0) / TP2 R:R (default 2.0) / TP3 R:R (default 3.0): risk-to-reward multiples
🔍 Filters:
— Volume Filter (default Off): breakout volume > SMA(20) × multiplier (default 1.5×)
— HTF Trend Filter (default Off): align breakouts with SMA(50) trend on HTF (default Daily)
🎨 Visual:
— Range boxes, resistance/support zones, centerline (all toggleable)
— Breakout signals, target levels, close labels (all toggleable)
— Squeeze background highlight (default Off)
— Configurable label sizes (signal, target, close — separate controls)
— Auto / Dark / Light theme
🔔 Alerts
— 🟢 BULL BREAKOUT / 🔴 BEAR BREAKOUT — ticker, price, SL, TP1, timeframe
— ✅ TP1 HIT / TP2 HIT / TP3 HIT — trade progress
— ✅ TP3 TRADE CLOSED — full win with P&L
— ❌ SL TRADE CLOSED — stopped out with P&L
All support plain text and JSON webhook format. Bar-close confirmed.
⚠️ IMPORTANT NOTES
— 🚫 No repainting. All breakout signals require barstate.isconfirmed. Range boxes are created on the bar after the squeeze ends (confirmed transition). TP/SL hit detection uses first-touch logic (current bar vs previous bar comparison). HTF filter uses + lookahead_on for non-repainting. A warmup period (max of squeeze length and 50 bars) prevents signals during insufficient data.
— 📐 The dual-engine squeeze is not a standard Bollinger/Keltner squeeze . It combines BB Width percentile compression with ATR contraction ratio — both must agree. This is stricter than a single-measure approach and produces fewer but higher-quality consolidation zones.
— ⚖️ The trade is tracked until TP3 or SL — there is no partial close logic. TP1 and TP2 are marked as they're hit (for visual reference and alerts) but the trade remains open until the final outcome. You can manage partial closes manually using the TP1/TP2 alerts.
— 📊 Signal strength reflects how many quality factors aligned at the time of breakout. A "Strong" signal had volume surge, HTF alignment, AND extended squeeze — but strength does not predict outcome.
— 🔄 If a new breakout occurs while a trade is active, the previous trade is replaced. The indicator tracks one trade at a time.
— 📏 Range box boundaries are adaptive Donchian — they expand during the squeeze to capture every high and low. They do not contract. This means the range can be wider than the BB Width suggests if a spike occurred during the squeeze.
— 🛠️ This is a breakout detection and target visualization tool , not an automated trading bot. It identifies squeeze zones, confirms breakouts, and places structural targets — trade decisions remain yours.
— 🌐 Works on all markets and timeframes. Volume filter auto-adapts to instruments without volume data.
Indicador Pine Script®






















