OPEN-SOURCE SCRIPT

Pattern Scout Wedges Head Shoulders

246
Pattern Scout — Wedges & Head/Shoulders

Pattern Scout automatically detects four classic chart patterns — falling wedges, rising wedges, head & shoulders, and inverse head & shoulders — and draws them directly on your chart as you scroll through history. It is a screening tool meant to surface candidates for you to review, not an automated signal generator.

▮ WHAT IT DOES
The script scans confirmed swing pivots and tests recent highs and lows against the geometric definition of each pattern. When a match is found, it draws the pattern's trendlines (or shoulder/neckline structure) and labels it. It does not repaint: a pattern is only drawn after its pivots are confirmed, so labels stay fixed once printed.

▮ HOW IT WORKS
Swing detection — Highs and lows are found using ta.pivothigh / ta.pivotlow with a configurable strength. A pivot needs N bars on each side to qualify, which is what prevents minor wiggles from registering as structure. This confirmation is also why a pattern appears a few bars after it visually completes — an unavoidable trade-off in any non-repainting swing method.

Wedges — The script takes the two most recent swing highs and the two most recent swing lows, fits a line through each pair, and checks two conditions: (1) both lines slope the same direction (down = falling wedge, up = rising wedge), and (2) the vertical gap between the lines at the end is narrower than at the start by at least the Convergence Ratio. This "narrowing channel" test is what separates a true wedge from a parallel channel. Lines are then clipped at their apex (the point where they mathematically intersect) so each wedge is a closed shape rather than two rays running off-screen.

Head & Shoulders — Looks at three consecutive swing highs. The middle high (the head) must exceed both outer highs (the shoulders), and the two shoulders must be within the Shoulder Symmetry tolerance of each other, measured as a fraction of head height. The neckline is drawn through the two intervening swing lows. Inverse H&S applies the mirror logic to three swing lows.

▮ SETTINGS
Swing strength — Bars required each side to confirm a pivot. Higher values find larger, rarer patterns with more confirmation lag. Start around 5 on intraday charts, 10–15 on daily.

Convergence ratio — How much a wedge must narrow to qualify (end gap ÷ start gap). Lower = stricter. Drop toward 0.4 if you get too many loose wedges.

Shoulder symmetry tolerance — Maximum allowed difference between the two shoulders. Loosen toward 0.08 if H&S rarely fires.

Require neckline break — When on, H&S only flags after price closes beyond the neckline. Fewer false alarms, more lag.

Max patterns kept on chart — Older patterns (lines and labels together) are automatically deleted once this cap is exceeded, keeping the chart readable.

Style — Per-pattern colours with adjustable transparency, plus an optional toggle to mark raw pivots.

▮ HOW TO USE IT
Treat each drawn pattern as a candidate, not a confirmed setup. Patterns are detected from the two most recent swings, so they are the simple two-touch variety rather than multi-touch channels. Always eyeball each one in context — chart-pattern recognition is inherently subjective, and the script will occasionally label structure that your eye would dismiss. Tune the three core knobs (swing strength, convergence ratio, shoulder symmetry) per instrument and timeframe to match your own reading.

Alerts are included for all four pattern types.

▮ LIMITATIONS
- Two-swing geometry only; it will not capture every variation of these patterns.
- Confirmation lag is intrinsic to non-repainting pivots.
- Pattern detection is a starting point for analysis, not a trading recommendation.

This script is provided for educational and analytical purposes. It does not provide financial advice and makes no claim about future price movement or profitability. Always do your own analysis and manage risk accordingly.

כתב ויתור

המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.