Head & Shoulders Auto Detector [AGPro Series]Head & Shoulders Auto Detector
🎯 **Overview**
Head & Shoulders Auto Detector is a precision pattern recognition tool that automatically identifies classic Head & Shoulders (bearish) and Inverse Head & Shoulders (bullish) reversal formations across any market and timeframe. Built from the ground up for traders who want the full lifecycle of a pattern tracked on-chart — not just a label and a line, but forming → confirmation → target/stop outcome — with a transparent, quality-scored framework that filters low-probability setups before they clutter the chart.
Every pattern carries a composite quality score, a symmetry percentage, an ATR-adaptive neckline, two projection targets, and a live status label that evolves through the pattern's lifespan.
🔹 **Unique Edge**
Most H&S indicators stop at detection. This one goes further:
• **Full lifecycle state machine** — every pattern moves through four explicit states (Forming → Confirmed → Target Hit / Stopped / Invalidated / Expired), and the visuals update in real time at each transition.
• **Dead pattern hygiene** — once a pattern fails or hits target, orphan TP and stop lines are removed, the neckline freezes at the decision bar, and the status label grays out. The chart never accumulates stale clutter.
• **Quality-driven visual hierarchy** — high-quality patterns (Q≥75) are rendered with a star marker and full saturation, mid-tier patterns get standard treatment, and low-tier patterns (Q<60) fade into the background so the trader's eye is guided to what matters.
• **Dual-target projection with R:R** — every confirmation displays both a classic measured-move TP1 and an extended 1.618× TP2, each labeled with the exact reward-to-risk ratio calculated at entry.
• **ATR-adaptive everything** — shoulder tolerance, neckline flatness, head prominence, stop buffer, and label offsets all scale with volatility, so the same settings work across BTC 4H, gold daily, or small-cap stocks.
🔹 **Methodology**
Patterns are detected from confirmed pivot highs and lows using a configurable pivot length. For a valid Head & Shoulders, three same-side pivots (Left Shoulder → Head → Right Shoulder) must satisfy:
• Head extends beyond both shoulders by at least the configured ATR multiple (prominence test).
• Shoulder heights differ by less than the shoulder tolerance in ATR units (symmetry test).
• Two opposite-side pivots between LS-Head and Head-RS define the neckline; their vertical distance must be within the neckline tolerance.
• Composite symmetry score (50% time symmetry, 50% price symmetry) must exceed the minimum threshold.
Quality score combines four weighted components:
• Symmetry (45%) — time + price balance between shoulders
• Neckline flatness (25%) — how horizontal the neckline is
• Volume profile (15%) — head-bar volume relative to shoulder average
• Head prominence (15%) — how clearly the head dominates
Confirmation triggers when price closes beyond the neckline level (interpolated for sloped necklines). Stop is placed at the head level plus an ATR buffer to avoid wick stop-outs. TP1 uses the standard head-to-neckline measured move; TP2 extends to 1.618× that projection.
🔹 **Signals & Alerts**
Four alert events available:
• **Pattern Forming** — a valid H&S or Inverse H&S structure has been detected but not yet confirmed.
• **Pattern Confirmed** — close has broken the neckline; entry is live with TP/Stop drawn.
• **Target Hit** — TP1 has been reached on a confirmed pattern.
• **Neckline Retest** — after confirmation, price has returned to touch the neckline (common high-probability re-entry zone).
🔹 **Key Inputs**
• **Pivot Length** — controls swing-point sensitivity
• **Min Symmetry Score** — minimum shoulder symmetry percentage to accept a pattern (default 60, balanced)
• **Neckline Tolerance (ATR)** — how sloped a neckline is allowed to be
• **Shoulder Height Tolerance (ATR)** — how different the two shoulders can be
• **Head Prominence (ATR)** — minimum head extension beyond shoulders
• **Volume Soft Confirmation** — toggle volume influence on quality score
• **TP1 Method** — Classic (horizontal neckline reference) or Measured Move (slope-aware)
• **Stop Buffer (ATR)** — extra room beyond the head level (default 0.35)
• **Max Pattern Lifetime** — bars after which an unconfirmed pattern expires
• Full visual controls: font size, panel position, theme, zone display, label offset, color palette
🔹 **How to Use**
1. Apply the indicator to any liquid market and timeframe. 4H and higher tend to produce the most reliable formations; intraday works but expects more noise.
2. Watch for patterns labeled with a ⭐ and bright color (Q≥75) — these are the highest-confidence setups.
3. Wait for the ✓ Confirmed status to appear before entering; the ⚡ breakout marker pinpoints the exact confirmation bar.
4. Use the TP1 / TP2 R:R labels to size the trade. Stop is pre-calculated at head level + ATR buffer.
5. Monitor the panel stats over time to understand the indicator's behavior on your specific market — Win Rate, Avg Quality, and Last Signal all update live.
6. Consider combining with trend context (a bearish H&S is far more powerful at resistance in a downtrend than in the middle of a strong uptrend).
🔹 **Limitations & Transparency**
• Pattern detection uses confirmed pivots, so signals appear with a natural delay equal to the Pivot Length setting. This is intrinsic to pivot-based logic, not a flaw.
• Quality score and historical win rate are chart-native calculations based on the loaded history; they are descriptive, not predictive.
• The script does not include multi-timeframe confluence or trend filters — these are deliberate design choices to keep the tool focused and composable with other indicators.
• Volume confirmation is a soft scoring input, not a hard filter, since many crypto pairs and indices have volume data of variable reliability.
• Pattern state transitions use close-based confirmation; intrabar wicks do not trigger state changes except for stop/target hits, which are high/low based as expected.
🔹 **Risk Disclosure**
This indicator is an analytical tool, not a trading recommendation or financial advice. Pattern recognition describes what has formed on a chart; it does not predict future price movement with certainty. Always use proper risk management, position sizing, and confirm signals with your own analysis. Past pattern statistics shown on the panel are descriptive of the visible history and do not guarantee future performance. Trading involves substantial risk of loss.
Pine Script® インジケーター












