Head shoulders bullish setup event
Marks an inverse head-and-shoulders setup; at default settings it never fires.
A six-state machine runs on the 100-bar channel, the lowest and highest close of the last 100 bars. It moves from a left shoulder (close within shoulder_eps of the low) through a rebound, a head (close more than head_eps below the low), a second rebound, and back to a right shoulder near the low, then marks that bar. The head test compares the close with a low that already includes the current close, so with the default positive head_eps it cannot pass and the machine stalls.
How to read it
- Markers appear on the candles only; there is no line or pane to read.
- A marker means price rebounded off its 100-bar low, dipped back toward it, rebounded again and returned within 0.5% of the low.
- With default settings the pattern showed no markers on a month of SPY bars.
What it outputs
- Bullish H&S setup
- Fires once, on the bar where price returns to within shoulder_eps of its 100-bar low to complete the right shoulder.
When it fires
Price touches the 100-bar low, rebounds, drops through the head test, rebounds again and returns to the low. That completes the right shoulder. It is a setup marker, not a buy signal: no neckline break is checked.
Settings
- shoulder_eps
- How close to the 100-bar low counts as a shoulder, as a fraction (0.005 is 0.5%). Higher values let more bars count as touching the low; below zero nothing can count.
- head_eps
- How far below the 100-bar low the close must fall to count as the head. Zero or above never passes, because that low already contains the current close. Only negative values let the setup advance, passing when the close is within that much above the low.
- pullback
- The rebound needed before each next step: close at least this fraction above the 100-bar low, or within this fraction of the 100-bar high. Higher values make the low route harder but the high route easier. Zero or below passes every bar.
Pitfalls
- Looks broken: with the default head_eps of 0.01 it never fires, and a month of SPY bars gave zero markers. Every negative head_eps tried fired exactly once in that month.
- It fires at most once per continuous run: the final state has no exit, so the pattern never re-arms.
- The 100-bar channel is built from closes, not intraday lows and highs, so the low is the lowest close.