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

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.050 to 10Smallest buffer of this detector, % of the close (each buffer is the larger of this and its ATR multiple).
zone_k0.250 to 5Thickness of a new zone in ATRs (from the pivot inward).
merge_k0.50 to 5A pivot this many ATRs or closer to a zone of its side joins it.
width_k1.50.1 to 10Widest zone after a merge, in ATRs.
invalid_k0.10 to 5A close this many ATRs beyond a zone's far edge ends the zone.
max_zones51 to 20Active zones kept (oldest dropped).
max_age_bars20010 to 2000Candles after its birth until a zone or level expires.
pick_rank11 to 5Pick outputs: 1 = the nearest zone, 2 = the next one out, …
pick_min_visits00 to 50Pick outputs: only zones visited at least this often.
pick_sideanyany, bull, bearnearest_low/high: zones of any side, or only the bull (support) or bear (resistance) side.

What it gives

OutputWhat it is
In a zoneTrue while the close is inside an active support/resistance zone.
In a support zoneTrue while the close is inside a support support/resistance zone.
In a resistance zoneTrue while the close is inside a resistance support/resistance zone.
Low edge of the zone aboveLow edge of the nearest support/resistance zone wholly above the close.
High edge of the zone aboveHigh edge of the nearest support/resistance zone wholly above the close.
Low edge of the zone belowLow edge of the nearest support/resistance zone wholly below the close.
High edge of the zone belowHigh edge of the nearest support/resistance zone wholly below the close.
Active zonesActive support/resistance zones (both sides).
Visits of the nearest zoneVisits 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 zoneTrue on the candle a support support/resistance zone is born.
New resistance zoneTrue on the candle a resistance support/resistance zone is born.
Support zone breakTrue on the candle a close goes through a support support/resistance zone (it ends).
Resistance zone breakTrue on the candle a close goes through a resistance support/resistance zone (it ends).
Low edge of the zone the close is inLow 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 inHigh 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 zoneTrue on the candle the first visit of a support support/resistance zone starts (its visits become 1).
First touch of a resistance zoneTrue on the candle the first visit of a resistance support/resistance zone starts (its visits become 1).
Low edge of the picked zoneLow 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 zoneHigh 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 zoneLow 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 zoneHigh 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 zoneLow 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 zoneHigh 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 zoneLow edge of the newest active support support/resistance zone, from the candle it is born (none before).
High edge of the newest support zoneHigh edge of the newest active support support/resistance zone, from the candle it is born (none before).
Low edge of the newest resistance zoneLow edge of the newest active resistance support/resistance zone, from the candle it is born (none before).
High edge of the newest resistance zoneHigh 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