Skip to content

Range Box

Volatility-bounded consolidation box detection with fakeout deviation/reclaim tracking and compression metrics.

range locates the most recent tight horizontal consolidation bounded by an ATR height cap, tracks wick or multi-bar deviations that reclaim inside the range, and detects sustained breakouts.

Parameters

Parameter Default Range Type Timeframe overrides
window 500 60..2000 integer —
maxHeightAtr 4 1..15 number —
minBars 12 5..300 integer 8 on >= 1d
lookback 200 20..2000 integer —

Algorithm & Nuances

  1. Backward box growth (rangeScan): Walks end bar e backward from n - 1 down to max(minBars - 1, n - 1 - lookback). For each e, extends start st backward while maxH - minL <= maxHeightAtr * atr[e]. Selects the most recent e spanning at least minBars.
  2. Boundary touches: Counts distinct touches of high and low within 0.25 * atr[e] separated by at least TOUCH_GAP = 3 bars.
  3. Deviation & reclaim tracking: Scans forward after e for fakeout excursions up to 1.5 * atr[k]:
    • Wick deviation: Single candle wicking >= 0.2 * atr[k] outside [low, high] and closing back inside extends the range right edge e and logs a Deviation.
    • Multi-bar reclaim: Close outside [low, high] that reclaims back inside within 1–3 bars (with max excursion <= 1.5 * atr[k]) extends e to the reclaim bar and logs a Deviation.
    • Caps recorded deviations at 4.
  4. Status & compression:
    • Status is 'active' when e === n - 1, 'broke up' or 'broke down' on a sustained close outside (with breakTime), or 'left' if the box ended without an active close beyond bounds.
    • compression = mean(atr[st..e]) / mean(atr[max(0, st - 14)..st - 1]) quantifies volatility contraction entering the box.

Drawings & Facts

  • Drawings: 0 or 1 zone box in 'accent' tone with a dashed 50% midpoint line (mid) and right-edge tags (Range high, Range low), plus up to 4 mark labels (Dev ↓ above / 'down', Dev ↑ below / 'up').
  • Facts (RangeFacts): box (from, to, high, low, mid, bars, heightAtr, status, breakTime, topTouches, bottomTouches, compression, positionInRange, deviations[]) or null.

Activation

  • Studies menu: Range box (Range)
  • Slash command: /range
  • Chat phrases: range, ranges, box, consolidation

Type to search…

↑↓ navigate↵ selectEsc close