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
| Setting | Default | Range | What it does |
|---|---|---|---|
| atr_period | 14 | 1 to 500 | ATR length (Wilder) for every buffer. |
| swing_k | 2 | 0.1 to 20 | Swing reversal in ATRs: a pivot is confirmed when a close moves this far back. |
| swing_min_pct | 0.1 | 0 to 10 | Smallest swing reversal, % of the close. |
| floor_pct | 0.02 | 0 to 10 | Smallest buffer of this detector, % of the close (each buffer is the larger of this and its ATR multiple). |
| min_bars | 10 | 2 to 1000 | Shortest pattern, in candles from its first to its last swing point. |
| max_bars | 150 | 3 to 2000 | Longest pattern; also how long a pattern waits for its breakout. |
| tol_k | 0.5 | 0 to 5 | Double top/bottom: largest difference of the two peaks, in ATRs. |
| depth_k | 1 | 0 to 20 | Double top/bottom: smallest depth between the peaks, in ATRs. |
| prom_k | 0.5 | 0 to 10 | Head and shoulders: the head stands out by at least this many ATRs. |
| shoulder_k | 1 | 0 to 10 | Head and shoulders: largest difference of the shoulders, in ATRs. |
| touches | 2 | 2 to 5 | Triangle: swing points on each line. |
| resid_k | 0.5 | 0 to 5 | Triangle: largest distance of a swing point from its line, in ATRs. |
| flat_k | 0.5 | 0 to 5 | Triangle: a line that moves less than this many ATRs over the pattern is flat. |
| break_k | 0 | 0 to 5 | A breakout close must pass the line by this many ATRs. |
What it gives
| Output | What it is |
|---|---|
| Double top | True on the close that confirms a double top. |
| Double bottom | True on the close that confirms a double bottom. |
| Double top neckline | Neckline of the waiting (or just confirmed) double top. |
| Double bottom neckline | Neckline of the waiting (or just confirmed) double bottom. |
| Head and shoulders | True on the close that confirms a head and shoulders top. |
| Inverse head and shoulders | True on the close that confirms an inverse head and shoulders. |
| Head and shoulders neckline | Neckline value now of the waiting (or just confirmed) head and shoulders. |
| Inverse head and shoulders neckline | Neckline value now of the waiting (or just confirmed) inverse head and shoulders. |
| Symmetrical triangle break up | True on a close above a symmetrical triangle. |
| Symmetrical triangle break down | True on a close below a symmetrical triangle. |
| Ascending triangle break up | True on a close above an ascending triangle. |
| Ascending triangle break down | True on a close below an ascending triangle. |
| Descending triangle break up | True on a close above a descending triangle. |
| Descending triangle break down | True on a close below a descending triangle. |
| Triangle upper line | Upper line value now of the waiting (or just broken) triangle. |
| Triangle lower line | Lower line value now of the waiting (or just broken) triangle. |
| Pattern stop level | Extreme 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