OPEN-SOURCE SCRIPT
Structured Head and Shoulder Pattern (MastersinMarkets)

[]Overview
This proprietary indicator automates the detection of classic Head and Shoulders (H&S) and Inverse Head and Shoulders patterns using a rigorous structural approach. Designed for traders who prioritize geometric symmetry and statistical quality, it filters out "noisy" or low-probability formations that often lead to false breakouts.
[]Core Logic
The script utilizes a multi-stage validation engine to confirm pattern integrity:
*Pivot Analysis: Identifies high-fidelity swing points using a configurable "Swing Strength" to ensure only significant market turns are considered.
*Symmetry Scoring: A proprietary algorithm evaluates patterns based on price symmetry (Shoulder height similarity), time symmetry (duration between peaks), and neckline slope.
*ATR Volatility Scaling: The "Min Pattern Size" filter ensures the pattern is large enough relative to current market volatility to be considered structurally significant.
[]Key Features
*Dynamic Quality Score: Every detected pattern is assigned a score (0–100). Only those meeting your "Min Quality Threshold" are displayed, helping you focus on high-probability setups.
*Flexible Necklines: Allows for both horizontal and sloping necklines with a "Max Slope" constraint to maintain structural validity.
*Visual Structure Mapping: Automatically plots the connecting lines of the pattern and extends the neckline for clear breakout monitoring.
*Real-time Alerts: Integrated alerts trigger the moment a validated pattern completes its Right Shoulder.
[]How It Works
*Detection: The script looks for a sequence of five swing points (High-Low-High-Low-High for bearish setups).
*Validation: It checks if the "Head" is higher than both "Shoulders" and if the distance between swings meets the minimum bar count.
*Scoring: It calculates the $Price\_Symmetry$,
TIME\_Ratio$, and $Slope\_Score$.
*Execution: If the cumulative score exceeds the user-defined threshold (e.g., 60), the pattern is drawn on the chart.
[]Disclaimer
Trading involves significant risk. This indicator is a tool for technical analysis and does not constitute financial advice. Past performance, including high-quality symmetry scores, does not guarantee future results. Always use proper risk management and consider market context before executing trades.
This proprietary indicator automates the detection of classic Head and Shoulders (H&S) and Inverse Head and Shoulders patterns using a rigorous structural approach. Designed for traders who prioritize geometric symmetry and statistical quality, it filters out "noisy" or low-probability formations that often lead to false breakouts.
[]Core Logic
The script utilizes a multi-stage validation engine to confirm pattern integrity:
*Pivot Analysis: Identifies high-fidelity swing points using a configurable "Swing Strength" to ensure only significant market turns are considered.
*Symmetry Scoring: A proprietary algorithm evaluates patterns based on price symmetry (Shoulder height similarity), time symmetry (duration between peaks), and neckline slope.
*ATR Volatility Scaling: The "Min Pattern Size" filter ensures the pattern is large enough relative to current market volatility to be considered structurally significant.
[]Key Features
*Dynamic Quality Score: Every detected pattern is assigned a score (0–100). Only those meeting your "Min Quality Threshold" are displayed, helping you focus on high-probability setups.
*Flexible Necklines: Allows for both horizontal and sloping necklines with a "Max Slope" constraint to maintain structural validity.
*Visual Structure Mapping: Automatically plots the connecting lines of the pattern and extends the neckline for clear breakout monitoring.
*Real-time Alerts: Integrated alerts trigger the moment a validated pattern completes its Right Shoulder.
[]How It Works
*Detection: The script looks for a sequence of five swing points (High-Low-High-Low-High for bearish setups).
*Validation: It checks if the "Head" is higher than both "Shoulders" and if the distance between swings meets the minimum bar count.
*Scoring: It calculates the $Price\_Symmetry$,
*Execution: If the cumulative score exceeds the user-defined threshold (e.g., 60), the pattern is drawn on the chart.
[]Disclaimer
Trading involves significant risk. This indicator is a tool for technical analysis and does not constitute financial advice. Past performance, including high-quality symmetry scores, does not guarantee future results. Always use proper risk management and consider market context before executing trades.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.