Support/resistance zones
Support and resistance zones built from confirmed swing points, with touches and breaks.
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.
Support/resistance zones 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. |
| pick_rank | 1 | 1 to 5 | Pick outputs: 1 = the nearest zone, 2 = the next one out, … |
| pick_min_visits | 0 | 0 to 50 | Pick outputs: only zones visited at least this often. |
| pick_side | any | any, bull, bear | nearest_low/high: zones of any side, or only the bull (support) or bear (resistance) side. |
What it gives
| Output | What it is |
|---|---|
| In a zone | True while the close is inside an active support/resistance zone. |
| In a support zone | True while the close is inside a support support/resistance zone. |
| In a resistance zone | True while the close is inside a resistance support/resistance zone. |
| Low edge of the zone above | Low edge of the nearest support/resistance zone wholly above the close. |
| High edge of the zone above | High edge of the nearest support/resistance zone wholly above the close. |
| Low edge of the zone below | Low edge of the nearest support/resistance zone wholly below the close. |
| High edge of the zone below | High edge of the nearest support/resistance zone wholly below the close. |
| Active zones | Active support/resistance zones (both sides). |
| Visits of the nearest zone | Visits of the nearest support/resistance zone (the one holding the close, else the closer of above/below); one continuous stay is one visit. |
| New support zone | True on the candle a support support/resistance zone is born. |
| New resistance zone | True on the candle a resistance support/resistance zone is born. |
| Support zone break | True on the candle a close goes through a support support/resistance zone (it ends). |
| Resistance zone break | True on the candle a close goes through a resistance support/resistance zone (it ends). |
| Low edge of the zone the close is in | Low edge of the support/resistance zone the close is inside (the most recently created if several); none outside every zone. A long's stop below the zone. |
| High edge of the zone the close is in | High edge of the support/resistance zone the close is inside (the most recently created if several); none outside every zone. A short's stop above the zone. |
| First touch of a support zone | True on the candle the first visit of a support support/resistance zone starts (its visits become 1). |
| First touch of a resistance zone | True on the candle the first visit of a resistance support/resistance zone starts (its visits become 1). |
| Low edge of the picked zone | Low edge of the pick_rank-th support/resistance zone (1 = nearest: one holding the close, else the closest) with at least pick_min_visits visits, of the pick_side side; inside it or not. |
| High edge of the picked zone | High edge of the pick_rank-th support/resistance zone (1 = nearest: one holding the close, else the closest) with at least pick_min_visits visits, of the pick_side side; inside it or not. |
| Low edge of the picked support zone | Low edge of the support pick_rank-th support/resistance zone (1 = nearest: one holding the close, else the closest) with at least pick_min_visits visits; inside it or not. |
| High edge of the picked support zone | High edge of the support pick_rank-th support/resistance zone (1 = nearest: one holding the close, else the closest) with at least pick_min_visits visits; inside it or not. |
| Low edge of the picked resistance zone | Low edge of the resistance pick_rank-th support/resistance zone (1 = nearest: one holding the close, else the closest) with at least pick_min_visits visits; inside it or not. |
| High edge of the picked resistance zone | High edge of the resistance pick_rank-th support/resistance zone (1 = nearest: one holding the close, else the closest) with at least pick_min_visits visits; inside it or not. |
| Low edge of the newest support zone | Low edge of the newest active support support/resistance zone, from the candle it is born (none before). |
| High edge of the newest support zone | High edge of the newest active support support/resistance zone, from the candle it is born (none before). |
| Low edge of the newest resistance zone | Low edge of the newest active resistance support/resistance zone, from the candle it is born (none before). |
| High edge of the newest resistance zone | High edge of the newest active resistance support/resistance zone, from the candle it is born (none before). |
What it reads
It reads the whole candle (open, high, low, close and volume).
Warm-up
With its default settings, Support/resistance zones needs 441 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 Support/resistance zones with its default settings