headAndShoulders
The Head and Shoulders pattern is one of the most recognized reversal formations. It uses seven swing points to build three peaks: two shoulders and one head in the middle. Traders use it to spot a possible trend reversal (from bullish to bearish, or the inverted version for bearish to bullish).
Syntax
headAndShoulders(leftBase, leftShoulder, leftNeck, head, rightNeck, rightShoulder, rightBase, styles?)
Parameters
leftBase (PricedData) · The start point at the base before the left shoulder.
leftShoulder (PricedData) · Peak of the left shoulder.
leftNeck (PricedData) · Valley after the left shoulder.
head (PricedData) · Highest (or lowest, in inverse) point of the pattern.
rightNeck (PricedData) · Valley after the head.
rightShoulder (PricedData) · Peak of the right shoulder.
rightBase (PricedData) · End base after the right shoulder.
styles (HeadAndShouldersStyleOverrides) · Style and display options:
backgroundColor(RGBAColor | BaseColors): background color used for the pattern area.bold(boolean): render text using a bold font weight.color(RGBAColor | BaseColors): line color of the pattern.fillBackground(boolean): fill the background area of the pattern.fontsize(number): font size used for text labels.italic(boolean): render text using italic style.linewidth(number): thickness of the pattern lines.textcolor(RGBAColor | BaseColors): color of the label text.transparency(number): transparency level.
Return Value
(string) · The drawing ID of the created Head and Shoulders pattern.
Example
Every 200 candles, we draw a Head and Shoulders using seven selected swing points.
Result

Tips
The neckline (connecting
leftNeckandrightNeck) is the key breakout level. Watch closely if price closes beyond it.Works both as a regular H&S (tops, bearish reversal) and inverse H&S (bottoms, bullish reversal).
Works best on higher timeframes for more reliable reversals.
Warning
Don’t force the pattern on random points — if the head isn’t clearly higher (or lower in inverse), the structure is invalid.
A sloping neckline is fine, but too extreme of an angle weakens the pattern.
Last updated