Breakout and retest
A close through a support or resistance zone, then a pullback to it that holds.
Support zones from confirmed swing lows, resistance zones from confirmed swing highs (swing params as swing). A new zone is zone_k ATRs thick from the pivot inward; a pivot within merge_k ATRs of the nearest zone of its side widens it (new version) while the zone stays at most width_k ATRs wide; zones never merge with each other. A close beyond the far edge by invalid_k ATRs breaks the zone (support_break / resistance_break) and removes it. Every buffer has the floor_pct % floor. Zones expire max_age_bars after birth; at most max_zones are kept. Built-in setup: a broken zone is frozen (the newest break replaces an older setup). bull_retest = a later candle touches the frozen resistance (low ≤ its high) and closes above it; bear_retest is the mirror. The setup ends at the retest, after retest_bars candles, or on a close back through the far edge (by invalid_k ATRs). frozen_level_low/high are the frozen zone's edges while a setup is open and on its retest candle (the retested zone wins over a break on the same candle), so a stop beyond the retested zone is ready on the signal candle.
Breakout and retest 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.05 | 0 to 10 | Smallest buffer of this detector, % of the close (each buffer is the larger of this and its ATR multiple). |
| zone_k | 0.25 | 0 to 5 | Thickness of a new zone in ATRs (from the pivot inward). |
| merge_k | 0.5 | 0 to 5 | A pivot this many ATRs or closer to a zone of its side joins it. |
| width_k | 1.5 | 0.1 to 10 | Widest zone after a merge, in ATRs. |
| invalid_k | 0.1 | 0 to 5 | A close this many ATRs beyond a zone's far edge ends the zone. |
| max_zones | 5 | 1 to 20 | Active zones kept (oldest dropped). |
| max_age_bars | 200 | 10 to 2000 | Candles after its birth until a zone or level expires. |
| retest_bars | 20 | 1 to 500 | Candles after the break in which the retest must come. |
What it gives
| Output | What it is |
|---|---|
| Bullish retest | True on the candle a broken resistance is retested from above and holds. |
| Bearish retest | True on the candle a broken support is retested from below and holds. |
| Broken zone low edge | Low edge of the frozen broken zone (also on its retest candle). |
| Broken zone high edge | High edge of the frozen broken zone (also on its retest candle). |
What it reads
It reads the whole candle (open, high, low, close and volume).
Warm-up
With its default settings, Breakout and retest needs 461 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 Breakout and retest with its default settings