Breakout Pattern Setup [WillyAlgoTrader]📐 Breakout Pattern Setup is an overlay indicator that automatically detects converging price channels (wedges, triangles, pennants) by fitting trendlines to confirmed pivot points using a boundary-fit algorithm, then monitors for breakouts confirmed by a 5-factor strength scoring engine — with directional probability scoring while price is inside the channel, volume contraction verification, and automatic TP/SL placement based on the measured move (channel width projected from breakout). Once a breakout fires, the trade stays open until TP3 (full measured move) or SL is reached — with trailing to breakeven after TP1.
The core concept: converging channels compress volatility — when price breaks out of a narrowing range, the ensuing move tends to be proportional to the channel's maximum width. This indicator automates the entire workflow: detect pivots, fit upper and lower trendlines, verify convergence and volume contraction, score the breakout quality when it occurs, set targets based on the measured move, and track the trade to completion.
🧩 WHY THESE COMPONENTS WORK TOGETHER
Manual channel drawing is subjective — two traders will draw different trendlines from the same pivots. A breakout without strength scoring treats strong and weak breaks equally. Targets without measured-move anchoring are arbitrary.
This indicator chains each component into a sequential pipeline:
Pivot detection → Boundary-fit algorithm (best trendline pairs) → Convergence + width + volume contraction verification → Channel visualization → Directional probability scoring → Breakout detection + 5-factor strength scoring → TP/SL from measured move → Trailing SL to breakeven after TP1 → Trade outcome tracking (win rate)
The pivot detection feeds raw swing points to the boundary-fit algorithm. The algorithm tests all pivot pair combinations and selects the lines with the most touches and least deviation — producing objective, reproducible trendlines. The convergence filter ensures only narrowing channels qualify (not parallel channels or expanding formations). Volume contraction confirms the volatility squeeze is genuine. The directional score gives real-time probability before the breakout occurs. The 5-factor strength score evaluates the breakout candle itself. And the measured-move TP/SL system manages the trade from entry through breakeven trail to final outcome.
🔍 WHAT MAKES IT ORIGINAL
1️⃣ Boundary-fit trendline algorithm.
The algorithm finds optimal upper and lower trendlines by exhaustive search over confirmed pivots:
Upper boundary: For every pair of pivot highs (A, B) within the lookback window:
— Project a line through A and B
— Check all other pivot highs: none may exceed the line by more than deviationMax × ATR (no overshoots beyond tolerance)
— Count how many pivot highs fall within touchTolerance × ATR of the line (touches)
— Keep the pair with the most touches
Lower boundary: Same process for pivot lows — no undershoot beyond tolerance, maximize touches.
A trendline is projected via: y = y1 + (y2 − y1) × (x − x1) / (x2 − x1). The touch tolerance (default 0.15× ATR) and deviation maximum (default 0.3× ATR) are both ATR-normalized, adapting to the instrument's volatility.
The scan runs on new pivots and every 10 bars (configurable interval), testing up to 15 recent pivots per side — producing the objectively best-fitting converging channel from available data.
2️⃣ Multi-criteria channel validation.
A detected channel must pass all five checks:
— 📏 Convergence : the channel is narrowing — current width < starting width. Convergence rate = 1 − (widthNow / widthStart) ≥ minConvergence (default 0.02 = at least 2% narrower)
— 📐 Width range : current width ≥ minChannelWidth × ATR (not too thin) AND < 10× ATR (not too wide)
— 📊 Volume contraction (when enabled): average volume inside the channel < 85% of average volume before the channel — confirms the volatility squeeze is accompanied by declining participation
— 📍 Price position : previous bar's close is inside the channel (not already broken out)
— ⚡ No inversion : upper boundary > lower boundary at the current bar
3️⃣ 5-factor breakout strength scoring (0–100).
When price closes beyond a channel boundary:
— 📏 Penetration depth (25%) : (close − boundary) / ATR, normalized to 0–1 (capped at 2× ATR). Deeper penetration = stronger commitment.
— 📊 Body ratio (15%) : candle body / candle range. Full-body candles (small wicks) indicate conviction. Doji/pin bars = weak.
— 📍 Body commitment (15%) : body midpoint beyond the boundary = 1.0, inside channel = 0.3. Full body commitment means the entire candle moved through, not just a wick.
— 📈 Volume confirmation (25%) : volume > SMA(20) × volumeSpikeMult = 1.0, otherwise 0.4. Above-average volume on the breakout bar confirms institutional participation.
— 💪 Momentum confirmation (20%) : RSI(14) > 50 for bullish (or < 50 for bearish) = 1.0, otherwise 0.4.
Classification: Strong (≥ 65), Medium (35–65), Weak (< 35). The strength is displayed on the breakout label and in the dashboard.
4️⃣ Directional probability scoring (0–100) while inside channel.
Before the breakout occurs, the indicator provides a real-time directional score:
— 📐 Channel slope bias (35%) : midline slope normalized by ATR — upward-sloping channels bias bullish, downward bias bearish
— 📊 RSI bias (35%) : (RSI − 50) / 50 — momentum direction
— 📍 Position in channel (30%) : (close − lower) / width — price near upper boundary biases bullish, near lower biases bearish
Score > 60% = bullish lean, < 40% = bearish lean, 40–60 = neutral. Displayed in the dashboard as "Bull Prob" — gives you a heads-up before the breakout direction is confirmed.
5️⃣ Measured-move TP/SL with trailing to breakeven.
On breakout:
— Target = breakout boundary + channel maximum width (the classic measured-move projection)
— TP1 = entry + fullMove / 3
— TP2 = entry + fullMove × 2/3
— TP3 = entry + fullMove (full measured move)
— SL = opposite channel boundary ± ATR padding (configurable, default 0)
After TP1 is hit, the SL moves to breakeven (entry price) — the entry label updates to show "(SL → BE)" and the original SL label dims. Trade stays open until TP3 (full measured move) or SL is reached. TP/SL labels show percentage distance from entry and update with ✓ / ✗ markers on hit. SL has priority on same-bar conflicts (SL checked before TPs).
6️⃣ Win/loss tracking with historical statistics.
The indicator tracks: total patterns detected, bull/bear breakout counts, wins (TP1 hit before SL), losses (SL hit before TP1), and win rate — all displayed in the dashboard. Two display modes: "All" (full history of all channels and trades) or "Last Only" (clean chart showing only the most recent pattern + trade, automatically cleaned up when a new pattern is detected).
7️⃣ Channel visualization with breakout color shift.
Before breakout: neutral channel lines (configurable color, default yellow) with optional fill. On bullish breakout: lines and fill shift to green. On bearish breakout: lines shift to red. Channel timeout (max width bars with no breakout) resets the scanner to look for new patterns.
⚙️ HOW IT WORKS — CALCULATION FLOW
Step 1 — Pivot detection: ta.pivothigh/ta.pivotlow with configurable lookback. Pivots stored in arrays (up to 60 recent, capped).
Step 2 — Boundary-fit scan: On new pivot or every 10 bars (if no active channel and no open trade): test all pairs of pivot highs for upper boundary, all pairs of pivot lows for lower boundary. Select best-fit lines by maximum touches.
Step 3 — Channel validation: Convergence rate ≥ minimum, width within range, volume contraction passes, price is inside, no inversion → channel activated.
Step 4 — Inside-channel monitoring: Directional probability score updated each bar. Channel lines extend. Background optional.
Step 5 — Breakout detection: Close beyond boundary + bar confirmed → 5-factor strength scoring → signal + TP/SL placement → channel lines recolored.
Step 6 — Trade tracking: TP1/TP2/TP3 and SL hit detection with SL priority. TP1 hit → trailing SL to breakeven. TP3 or SL → trade closed, channel reset, scanner resumes.
📖 HOW TO USE
🎯 Quick start:
1. Add the indicator — it scans for converging channels automatically
2. Yellow channel lines appear when a valid pattern is detected
3. Dashboard shows "Active" + "Bull Prob" percentage
4. On breakout → "Long"/"Short" label + Entry/SL/TP1–TP3 lines appear
5. TP1 hit → SL moves to breakeven. TP3 → trade complete.
👁️ Reading the chart:
— 🟡 Channel lines = active converging pattern (pre-breakout)
— 🟢 Channel turns green = confirmed bullish breakout
— 🔴 Channel turns red = confirmed bearish breakout
— 🟢 "Long" / 🔴 "Short" label = confirmed breakout signal with strength
— 🔵 Blue line = entry, 🔴 red = SL, 🟢 green dashed = TP1/TP2/TP3
— ✓ on TP labels = target hit, ✗ on SL = stopped out
📊 Dashboard fields:
— Pattern: Active / Bull Break / Bear Break / Scanning
— Strength: Strong / Medium / Weak (5-factor score)
— Trade: Active / TP1 ✓ (BE) / TP2 ✓ / TP3 ✓ / SL Hit
— Bull Prob: directional probability (0–100%) while inside channel
— R:R (TP1): risk-to-reward ratio
— Touches: upper/lower boundary touch counts
— Vol Contraction: in-channel vs pre-channel volume ratio
— Convergence: narrowing rate percentage
— Patterns / Breaks / Win Rate: cumulative statistics
🔧 Tuning guide:
— No patterns found: decrease Min Touches (2), increase Max Channel Width (150+), decrease Min Convergence (0.01)
— Too many weak patterns: increase Min Touches (3), increase Min Channel Width ATR (0.7+)
— Weak breakouts: increase Volume Spike Mult (1.5+), enable Momentum Confirmation
— SL too tight: increase SL Padding (0.2–0.3 ATR)
— Want clean chart: set Pattern History to "Last Only"
⚙️ KEY SETTINGS REFERENCE
⚙️ Main:
— Pivot Detection Length (default 5): swing lookback
— Min Touches (default 2): pivots per boundary
— Max Channel Width (default 120 bars): lookback limit
— Min Convergence Rate (default 0.02): narrowing threshold
🔍 Filters:
— Volume Spike Mult (default 1.2): breakout bar volume requirement
— Volume Contraction (default On): require declining volume in channel
— Momentum Confirmation (default On): RSI alignment
🛡️ Risk:
— SL Padding (default 0 ATR): buffer beyond opposite boundary
— Label Offset (default 20 bars): right-side level label distance
🔧 Advanced:
— Touch Tolerance (default 0.15 ATR): pivot proximity to trendline
— Max Deviation (default 0.3 ATR): maximum pivot overshoot
— Min Channel Width (default 0.5 ATR): filter out thin channels
📐 Channel Lines:
— Show Channel Fill (default On), color and width configurable
🔔 Alerts
— 🟢 BUY / 🔴 SELL — breakout with strength, entry, SL, TP1–TP3
— 🟡 PATTERN DETECTED — new channel found
— 🎯 TP1 / TP2 / 🏆 TP3 HIT — trade progress
— 🛑 SL HIT — stopped out
All support plain text and JSON webhook format. Bar-close confirmed.
⚠️ IMPORTANT NOTES
— 🚫 No repainting. All breakout signals require barstate.isconfirmed. Channel detection runs on confirmed pivots (equal left/right lookback). The boundary-fit algorithm selects the best trendlines from historical pivots — the resulting lines are objective and reproducible.
— 📐 The boundary-fit algorithm tests all valid pivot pairs (up to 15 per side) and selects the combination with the most touches that satisfies the deviation constraint. This is an exhaustive search, not a linear regression — it produces the tightest-fitting boundary lines possible from the data.
— ⚖️ The measured-move target (channel width projected from breakout) is the classic technical analysis projection for converging patterns. TP1/TP2/TP3 divide this move into thirds: TP1 = 33%, TP2 = 67%, TP3 = 100% of the projected move.
— 📊 Volume contraction compares average volume inside the channel vs before the channel over the same number of bars. A ratio below 85% confirms genuine volatility compression.
— 🔒 Once a breakout fires, the trade stays open until TP3 or SL is reached — there is no intermediate invalidation. The channel remains active while the trade is open. Channels without a breakout timeout after the max channel width in bars.
— 📏 SL priority: on a bar where both SL and TP are touched, SL is checked first . After TP1, SL moves to breakeven (entry price).
— 🛠️ This is a pattern detection and breakout scoring tool , not an automated trading bot. It identifies converging channels, scores breakouts, and sets measured-move targets — trade decisions remain yours.
— 🌐 Works on all markets and timeframes. Volume features auto-adapt to instruments without volume data.
Pine Script® indicator






















