TradingView chart patterns

Head and shoulders stock pattern: neckline and invalidation

A head and shoulders stock pattern is a possible bearish reversal after a rise: a left peak, a higher central peak and a lower right peak. The two outer peaks are the shoulders; the central peak is the head. A line through the intervening lows forms the neckline. The shape becomes a confirmed breakdown only when its neckline-break rule is met. A wick below the line is insufficient for a rule that requires a completed close.

See the decision guide

Make the shoulder and head rules measurable

The preceding rise supplies the reversal context. Three peaks in an existing decline do not establish the same hypothesis. For a custom detector, use one swing-selection rule throughout and specify both price tolerance and spacing. The following hypothetical specification uses standard price candles and arithmetic prices; its thresholds are examples, not TradingView defaults or recommended settings.

  • For this example, keep the latest five alternating pivots. Before candidate creation, replace consecutive same-side pivots only with a more extreme one; if a bar qualifies as both a high and a low, skip it. Freeze the five points once the candidate becomes eligible.
  • A right shoulder at 62 would fail the stated shoulder tolerance even though it remains below the head. Raising the tolerance afterward would change the detector.
  • The head-to-neckline height must be positive. A percentage of that height is different from a percentage of the stock price; label the denominator.
  • A fixed 3-unit prominence filter will behave differently on stocks with different price levels. Any percentage or volatility-based replacement needs its own specification and test.
DecisionIllustrative ruleExample
Prior riseLeft shoulder is at least 10% above the lowest low of the preceding 20 bars; all 20 bars must existA prior low of 50 and left shoulder of 60 pass
Swing sequenceUse five alternating confirmed extremes; each must be strictly beyond the three bars on each side, with ties rejectedHigh 60, low 55, high 66, low 57, high 60.5
Head prominenceHead exceeds both shoulders by at least 3 price units66 - 60.5 = 5.5 passes
Shoulder toleranceAbsolute shoulder difference is at most 15% of the head-to-neckline height measured at the head barHeight 10 gives tolerance 1.5; difference 0.5 passes
SpacingEach shoulder-to-head interval is 10 to 30 barsShoulders at bars 10 and 50, head at 30: both intervals are 20

Calculate the neckline on the bar being tested

Let the first intervening low be L1 at bar b1 and the second be L2 at bar b2, with b2 > b1. In linear price space, the neckline at bar t is N(t) = L1 + (L2 - L1) × (t - b1) / (b2 - b1). With low 55 at bar 20 and low 57 at bar 40, N(t) = 55 + 0.1 × (t - 20). At the head bar 30, the line is 56, so the head height is 66 - 56 = 10.

  • A fresh close-based breakdown requires previous close ≥ N(t - 1) and current close < N(t). Both comparisons use the line value for their own bar.
  • An upward slope raises the threshold with time. At bars 52 and 53, the neckline is 58.2 and 58.3. Closes of 58.25 then 58.28 cross below it even though price rises. If the hypothesis requires price to fall too, add current close < previous close explicitly.
  • A descending neckline lowers the threshold, so price may fall without crossing it. A horizontal neckline has a constant threshold.
  • Freeze the anchor bars and prices; do not redraw them with later lows to create an earlier signal. Logarithmic interpolation is a different calculation and should not be mixed with this arithmetic example.

Follow the confirmation sequence without backdating

This hypothetical timeline uses the five prices above. Assume all selected pivots pass the stated swing rule. The right shoulder occurs at bar 50, but the detector needs three subsequent completed bars before using it. A label drawn at 50 is a location marker, not evidence that a signal was available then.

  • The crossing may occur on the pivot confirmation bar. If it happened earlier, this example requires a new crossing after eligibility; it never inserts an alert into the past.
  • Before confirmation, invalidate an eligible candidate if a completed bar has a high above the saved head. Otherwise allow 20 bars starting with the eligibility bar; if none crosses, expire the candidate after that window.
  • For this example, eligibility at 53 gives a window from 53 through 72 inclusive. Consume the candidate after one breakdown; require a new confirmed swing before considering another candidate.
  • TradingView documents that historical pivot drawings can appear on earlier bars after later data confirms them. Review the event timestamp separately from the drawing timestamp. Waiting for bar close does not eliminate every source of repainting in a script.
TimeInformation availablePermitted action
Bar 30The head reaches 66; the right shoulder does not exist yetNo completed head and shoulders candidate
Bar 50The potential right shoulder reaches 60.5Wait for the right-side swing checks
Close of bar 52Close is 58.7; neckline is 58.2; only two bars follow the shoulderNo confirmed right shoulder or breakdown event
Close of bar 53The third right-side bar completes; close is 58.1 versus neckline 58.3Create the candidate and record its first eligible breakdown on bar 53
Later barsNew prices can reclaim the neckline or exceed the right shoulderRecord subsequent failure conditions without deleting the original event

Separate a failed break from a different pattern

A neckline reclaim and a right-shoulder breach answer different questions. Under the custom rules here, a later close above the saved right shoulder ends the bearish setup. A close back above the neckline is recorded as an earlier warning. These rules describe state transitions; an executable strategy still needs its own entry, exit and order-fill rules.

  • A post-break retest is optional. Requiring price to return to the neckline and close below it changes the sample and can exclude breaks that never return.
  • Volume can be tested as an additional condition, but it is not part of the price-only example above. Specify the volume source and comparison period before adding a filter.
  • No success rate follows from the shape alone. Compare fixed rules on a separate period and include failed candidates, transaction costs and adverse fills in any strategy evaluation.
CaseWhat changesInterpretation
Candidate invalidationPrice exceeds the head before an eligible breakdownNo confirmed bearish event occurred
Neckline reclaimAfter the example breakdown, bar 54 closes at 59 above N(54) = 58.4The break occurred, but price is back above its threshold
Failure under the chosen ruleA later close reaches 60.8, above the right shoulder at 60.5End the setup and retain the failed outcome in the log
Triple topAll three peaks occupy a similar resistance area without a distinct higher headUse a three-top specification instead of loosening this head rule
Inverse head and shouldersThree lows have a deeper middle trough, with a neckline through the intervening highsA separate bullish reversal hypothesis with an upward confirmation test

Read TradingView states before drafting a detector

TradingView documents 5/5 pivots for its built-in Head And Shoulders pattern. In Progress mode can include an unconfirmed right shoulder. Pattern Formed requires a close beneath the neckline, while its Failed status refers to price rising above the right shoulder before the target is reached. The custom 3/3 and close-based failure rules on this page do not reproduce that indicator.

  • Give Pineify AI Coding Agent the swing rule, shoulder tolerance, head prominence, neckline formula, eligibility time, expiry and failure conditions together. Ask for distinct candidate, confirmation and failure events.
  • Request a Pine Script draft with event markers on the bar where the information becomes available. Review it and request syntax validation before using TradingView replay to inspect the transitions.
  • Compilation checks language errors. It cannot prove that historical labels match live availability or that the pattern is profitable.
Where Pineify fits

Pine Script AI Coding Agent

Draft a custom head and shoulders detector from explicit rules, then review its candidate, confirmation and failure timestamps. Pineify can help write the script; this page does not scan stocks or provide a validated trading signal.

Draft head and shoulders rules

Frequently asked questions

Educational information, not investment advice. All prices, bar numbers and numerical thresholds are hypothetical. No historical or live performance is reported. A confirmed pattern can fail and does not guarantee a profitable trade.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.