zones finds institutional supply and demand bases (order blocks) that launched strong multi-candle ATR impulses, tracks retests and mitigation depth, and prunes invalidated zones once price closes through their far edge.
Parameters
Parameter
Default
Range
Type
Timeframe overrides
window
500
60..2000
integer
—
impulseAtr
2
0.8..8
number
2.5 on <= 5m
maxBase
4
1..10
integer
—
baseBody
0.5
0.1..0.9
number
—
max
4
1..10
integer
—
Algorithm & Nuances
Impulse detection (zoneScan): Scans for 1–3 consecutive same-direction candles each having body ratio |c - o| >= 0.5 * (h - l) and achieving net move dir * (c[k] - o[i]) >= impulseAtr * atr[i - 1].
Base extraction: Looks back up to maxBase basing candles with body ratio |c - o| <= baseBody * (h - l):
Demand zone: low = min(l), high = max(o, c) (upper body edge down to base low).
Supply zone: high = max(h), low = min(o, c) (lower body edge up to base high).
Minimum thickness: If high - low < 0.25 * atr[i - 1], widens to the full wick envelope [min(l), max(h)].
Confluence features: Records volRatio = clamp(max(v[imp..]) / medVol, 0.5, 3) and sets hasFvg = true if any impulse candle left a 3-bar gap >= 0.2 * atr[k].
Testing & invalidation (zoneTests): Walks from imp + len to n - 1:
Invalidation: Any close breaking the far edge (c < low for demand, c > high for supply) removes the zone completely.
Penetration & status: Counts distinct re-entries (tests) and deepest penetration (deepestPenetration in [0, 1]). Status is 'fresh' (tests === 0), 'mitigated' (deepestPenetration >= 0.5), or 'tested'.
Overlapping zones of the same kind replace the older zone with the newer one.
Selects up to ceil(max / 2) zones below/at close and ceil(max / 2) above close, backfilling to max, sorted descending by high.
Drawings & Facts
Drawings: Up to maxzone rectangles from baseFrom to the latest closed bar ('up' demand, 'down' supply; 'faint' when mitigated). Labels show (Demand|Supply) · (fresh|N% filled|tested N×) plus · FVG when paired with an imbalance.