OPEN-SOURCE SCRIPT
Pattern Scout Wedges Head Shoulders

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.
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.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.