Head shoulders breakout buy sell
Head-and-shoulders neckline breaks, but at default settings it never fires on SPY.
It reads the 100-bar high and low (a Donchian channel) and runs two one-way state machines. The sell side waits for a head-and-shoulders top: a left shoulder near the high, a pullback, a head above the high, a second pullback, a right shoulder near the high, then a close near the 100-bar low. The buy side mirrors it as an inverse head-and-shoulders bottom that signals near the 100-bar high. Once a pattern completes it stays armed, so it keeps signalling whenever price returns to the neckline.
How to read it
- Markers sit on the candles, not in a pane below: buy marks the buys and sell marks the sells.
- With default settings there are no markers at all, so set a negative band and head_eps first (see Try).
- A sell marker means a head-and-shoulders top finished earlier and price is now within the band of the 100-bar low.
- A marker can come long after its pattern formed, because a completed pattern stays armed.
What it outputs
- Buy (inverse head and shoulders)
- An inverse head-and-shoulders bottom has completed and price is within the band of the 100-bar high. Marks the first bar it holds.
- Sell (head and shoulders top)
- A head-and-shoulders top has completed and price is within the band of the 100-bar low. Marks the first bar it holds.
When it fires
Buy: an inverse head-and-shoulders bottom has completed and price is within the band of the 100-bar high. Sell: a head-and-shoulders top has completed and price is within the band of the 100-bar low. Completed patterns stay armed, so markers can keep coming long after the formation.
Settings
- shoulder_eps
- How close a bar must sit to the 100-bar high (or low, for the buy side) to count as a shoulder. Raising it lets more bars qualify, so patterns complete more easily. Lowering it needs a close almost on the extreme.
- head_eps
- The head's reach past the 100-bar extreme. Zero or positive removes every marker, since a close cannot clear that extreme. Negative values, like -0.005, need only a close within that share of it, mostly changing when a pattern arms.
- pullback
- Retracement needed between the peaks. Price must fall this far below the 100-bar high, or come within this distance of the 100-bar low. Raising it loosens the low-side test and tightens the high-side test; lowering it does the reverse.
- band
- Buffer past the neckline (100-bar low for sells, high for buys). Zero or positive removes every marker, since price cannot pass its own window extreme. Negative values fire when price is within that share of the neckline; more negative fires more.
- confirm_days
- Consecutive bars the break condition must hold before a signal fires. The marker lands on the bar that reaches this length, so raising it cuts signals and delays each one.
Pitfalls
- At default settings it never fires on the SPY one-minute bars tested (Sep 2026). The head needs a close 1% above the 100-bar high, which cannot happen, and band 0 needs a close beyond it too.
- Neither the neckline nor the head is a real break or a higher peak: all steps compare price to the same 100-bar window, so negative settings mean near, not through. Slope inputs are accepted but never used.
- The machine never resets. A completed pattern stays armed for the rest of the run, so markers can appear long after the pattern formed, with no new head or shoulders forming.