Chart patterns

Double tops and bottoms, head and shoulders and triangles, signalled on their breakout.

Chart patterns from confirmed swing pivots (swing params as swing), set up on the pivot that completes them with their lines frozen, then signalled on the close through the line. Double top: two highs within tol_k ATRs, at least depth_k ATRs above the low between them; break = close below that low. Head and shoulders: a head at least prom_k ATRs above shoulders within shoulder_k ATRs; break = close below the neckline through the two lows. Triangles: least-squares lines through the last touches swing highs and lows (each within resid_k ATRs), converging; a line moving less than flat_k ATRs is flat (ascending = flat top, descending = flat bottom, symmetrical = both sloped). Patterns last min_bars to max_bars candles and wait max_bars candles for the break; a close beyond the extreme (or meeting lines) cancels them. Every buffer has the floor_pct % floor. Mirrors are the inverse patterns. pattern_stop = the extreme of the last confirmed pattern (its lowest swing point after an upward break, its highest after a downward one), from the confirming close until the next confirmation, at most max_bars candles (none when patterns break both ways on one candle).

Chart patterns is a structure detector: it marks price structure on the chart and counts against the plan's detector limit.

Settings

SettingDefaultRangeWhat it does
atr_period141 to 500ATR length (Wilder) for every buffer.
swing_k20.1 to 20Swing reversal in ATRs: a pivot is confirmed when a close moves this far back.
swing_min_pct0.10 to 10Smallest swing reversal, % of the close.
floor_pct0.020 to 10Smallest buffer of this detector, % of the close (each buffer is the larger of this and its ATR multiple).
min_bars102 to 1000Shortest pattern, in candles from its first to its last swing point.
max_bars1503 to 2000Longest pattern; also how long a pattern waits for its breakout.
tol_k0.50 to 5Double top/bottom: largest difference of the two peaks, in ATRs.
depth_k10 to 20Double top/bottom: smallest depth between the peaks, in ATRs.
prom_k0.50 to 10Head and shoulders: the head stands out by at least this many ATRs.
shoulder_k10 to 10Head and shoulders: largest difference of the shoulders, in ATRs.
touches22 to 5Triangle: swing points on each line.
resid_k0.50 to 5Triangle: largest distance of a swing point from its line, in ATRs.
flat_k0.50 to 5Triangle: a line that moves less than this many ATRs over the pattern is flat.
break_k00 to 5A breakout close must pass the line by this many ATRs.

What it gives

OutputWhat it is
Double topTrue on the close that confirms a double top.
Double bottomTrue on the close that confirms a double bottom.
Double top necklineNeckline of the waiting (or just confirmed) double top.
Double bottom necklineNeckline of the waiting (or just confirmed) double bottom.
Head and shouldersTrue on the close that confirms a head and shoulders top.
Inverse head and shouldersTrue on the close that confirms an inverse head and shoulders.
Head and shoulders necklineNeckline value now of the waiting (or just confirmed) head and shoulders.
Inverse head and shoulders necklineNeckline value now of the waiting (or just confirmed) inverse head and shoulders.
Symmetrical triangle break upTrue on a close above a symmetrical triangle.
Symmetrical triangle break downTrue on a close below a symmetrical triangle.
Ascending triangle break upTrue on a close above an ascending triangle.
Ascending triangle break downTrue on a close below an ascending triangle.
Descending triangle break upTrue on a close above a descending triangle.
Descending triangle break downTrue on a close below a descending triangle.
Triangle upper lineUpper line value now of the waiting (or just broken) triangle.
Triangle lower lineLower line value now of the waiting (or just broken) triangle.
Pattern stop levelExtreme of the last confirmed pattern: its low after an upward break, its high after a downward one (the stop beyond the pattern).

What it reads

It reads the whole candle (open, high, low, close and volume).

Warm-up

With its default settings, Chart patterns needs 391 closed candles before its first value. A backtest loads them before its start date, so the first trade can already use it.

Test it

Copy this sentence into the Algonney chat to backtest it:

Backtest a strategy on BTC that uses Chart patterns with its default settings