2013issue C0550-56
Algorithmic head-and-shoulders construction with bounded exits
A mechanical head-and-shoulders detector can locate milestone-points, draw a neckline when those points satisfy the stated conditions, and place a setup label after the last qualifying bar. Editorial: first make that geometry machine-checkable, then attach a trailing-stop and atr-position-sizing so the same setup can be accepted or rejected before capital is committed.
- A mechanical detector locates milestone-points, draws a neckline when the stated conditions hold, and places a setup label after the last qualifying bar.
- Peaks and troughs can be found with a percentage-reversal test; extra pattern filters reduce the number of signals and add a degree of freedom for each extra variable or constant.
- A complete mechanical rule set can enter when a neckline through the two shoulder troughs, extended to the right, is broken, then exit at a measured objective or on a failed break.
- After the pattern is coded, it can be reused as a pullback-in-trend long, with a trailing-stop at three times a 39-day average true range from the close, entry on the following day's open, and fixed-fractional atr-position-sizing.
Locate milestone-points and draw the neckline
A mechanical head-and-shoulders detector can locate the pattern's key points, draw a neckline when those points satisfy the stated conditions, and place a setup label after the last qualifying bar. Those key points are the milestone-points the detector must locate and test against pattern conditions before a neckline or setup label is drawn.
A head-and-shoulders top can be stated as three peaks in which the middle peak is higher than the two outer peaks. In the sense used here, head-and-shoulders is a three-peak or three-trough price structure whose middle extreme is more pronounced than the two flanking extremes, with a neckline through the intervening troughs or peaks used as the confirmation line.
Find peaks and troughs with a percentage-reversal
Peaks and troughs for that geometry can be found by requiring a percentage-reversal in the high or low series at least as large as a chosen reversal amount. A percentage-reversal registers a peak or trough only after price retraces at least a stated percentage from a new extreme.
Inspect the same geometry on a chosen interval
Implementations expose chart-level parameters for price source, maximum pattern length, and neckline display so the same geometry can be inspected on a chosen bar interval and lookback. The neckline is the line through the two intervening troughs of a topping structure, or the two intervening peaks of a bottoming structure, extended forward as the confirmation threshold.
Extra filters add degrees of freedom
Adding extra pattern filters can reduce the number of signals and each extra variable or constant adds a degree of freedom to the resulting system.
Enter on a neckline break
A complete mechanical rule set can enter when an imaginary neckline through the two shoulder troughs, extended to the right, is broken, then exit at a measured objective or when price produces a failed break.
Scan completed and emerging patterns
The same geometry can be scanned for completed and emerging tops and for completed and emerging inverse bottoms, with reports that list every nonzero pattern flag. An emerging-pattern is a partially formed head-and-shoulders geometry that a scanner can flag before the neckline break completes.
Head-and-shoulders pattern length by Excel search start bar

The scan counted 35 hits over 692 bars examined (700 visible). Only the 17 rows in the visible pane are plotted; the remaining hits are off-screen.
Reuse the geometry as a pullback in trend
After the pattern is coded, it can be reused as a pullback long when a 50-day simple moving average is above a 200-day simple moving average and the head-and-shoulders setup confirms. That reuse is a pullback-in-trend: a completed topping geometry used as a long entry when a longer moving-average pair still defines an uptrend.
That construction places a trailing-stop at three times a 39-day average true range from the close, with entry on the following day's open. The trailing-stop trails a multiple of average true range from the close so the loss bound moves with realized volatility after entry.
Unit size can be set with a fixed-fractional money manager that risks 0.05% of total equity per trade when the book is a large equity index membership list. That atr-position-sizing rule scales the unit from account equity and a volatility-based stop distance so each trade risks a stated share of equity.
All readings on this track · 36 readings
- 1988Constructing unsigned true range for directional models
- 1989Evaluate an always-in ATR breakout as one procedure
- 1992Variable lookback and average true range as a trend-filter construction
- 1993A random-walk index that uses true range as its scale
- 1993A shared harness for trend-filter construction
- 1998Finish a trend with a volatility trail, wave permission, and a slower-frame veto
- 1999A trend filter that switches tactics and scales ATR targets
- 2001Filter higher lows with linear regression, then judge the exit
- 2003A Mechanical trading system is a maintained procedure, not only an entry trigger
- 2005Construction of a volatility-bounded long entry
- 2005Six-zone encoding of open, high, low, and close
- 2006Normalized average true range as a pre-entry volatility bound
- 2006Chandelier exits, ATR position sizing, and trailing stops
- 2007Constructing a rule-based entry with Relative Strength Index and ATR position sizing
- 2008Constructing a zero-lag TMA and heikin-ashi crossover as a complete rule set
- 2010Use the session-range percent stop as a pre-trade filter
- 2011OCA exit groups, trailing limits, and ATR stops
- 2011ATR bands around support and resistance for stops and targets
- 2013Algorithmic head-and-shoulders construction with bounded exits
- 2013Constructing ATR-scaled swing pivots and linear-regression divergence
- 2013Constructing volatility bands from typical price
- 2014Constructing true-range contraction filters before expansion
- 2015Constructing touch plans from modified true range
- 2015One checklist for breakout entry and ATR risk
- 2015Percentage true-range construction for cross-market volatility filters
- 2015Construct a percentage true range for cross-market volatility
- 2015Percentage true range as a pre-entry exposure filter
- 2016Constructing ATR-filtered breakout entries
- 2017A dividend date as a pairs-trading classroom
- 2018Range-based volatility as a true-range construction
- 2018Moving average support and volatility-band construction
- 2018Construct a lifecycle breakout from compression
- 2018Pair the book first and let volatility or range set the size
- 2019Trend systems need a no-trade rule
- 2020Average true range as a shared unit for size, pairs, and stops
- 2020Volatility sizing and target-risk leverage as a pre-trade gate