[TA] Range Regime

## Short Description
Tracks current candle range vs historical average, flags range spikes, and labels volatility regime (LOW / NORMAL / HIGH) at a glance.
---
## What It Does
Range Regime (RR) is a volatility/range monitoring indicator designed to help you quickly understand whether the market is *quiet, normal, or expanding* on the current timeframe.
It calculates:
* Current Range
* Either Candle Range (High–Low) *or* True Range (TR)
* Average Range over a lookback window (optionally smoothed)
* Max / Min / Mid range levels over the same lookback
* Spike detection
* Marks candles where current range is ≥ (Spike Threshold × Average)
* Regime state
* Compares the current range vs a longer Baseline Average
* Labels LOW / NORMAL / HIGH volatility regime in a small table
It also shows a compact stats table with points and ticks (based on `syminfo.mintick`) so you can think in the units you actually trade.
---
## Why It’s Helpful
This tool is useful because range expansion and compression often determine:
* Whether a setup is worth taking right now
* Whether your stops/targets are realistic for the session
* Whether you should size down (high regime) or avoid forcing trades (low regime)
* When the market is shifting from chop → impulse (spikes) or impulse → stall (compression)
In practice, RR helps you answer:
* “Is volatility expanding or contracting?”
* “Is this move unusually large relative to recent history?”
* “Are we in a high-vol environment where risk needs to change?”
---
## How To Use It
1. Add to chart (it plots in its own pane).
2. Choose your Range Mode:
* Candle (H–L): pure bar range (great for clean range monitoring)
* True Range (TR): includes gaps (better for overnight / news / gap-prone markets)
3. Set Lookback (N):
* Typical: 20–100
* Smaller = more reactive, larger = more stable
4. Optionally enable Smooth the Average:
* Helps reduce noise and false “spike” triggers
5. Adjust Spike Threshold (× Avg):
* Common values:
* 1.3–1.6 = more frequent spike flags
* 1.8–2.5 = only “real” expansions get flagged
6. Set Baseline Length (Regime):
* Typical: 150–300
* This is your “background volatility context”
---
## How To Read The Plots
* Current Range (columns): what the market just “spent” in range.
* Avg: normal range for this timeframe.
* Max / Min: extremes over the lookback window.
* Mid: midpoint between Max and Min (quick “center” reference).
* Spike Line (× Avg): the threshold for a “spike.”
* Background highlight: appears when the current candle qualifies as a spike.
* Regime table (top-left):
* HIGH when current range > 1.25× baseline average
* LOW when current range < 0.75× baseline average
* Otherwise NORMAL
---
## Practical Trading Uses (Examples)
* Risk calibration: If regime is HIGH, consider wider stops / smaller size.
* Trade selection: Avoid mean-reversion scalps when spikes are frequent (momentum environment).
* Session context: Spot when market transitions from tight range (LOW) into expansion (spike + HIGH).
* Instrument comparison: Great for comparing how “active” ES vs NQ vs CL is *on the same timeframe*.
---
## Suggested Defaults
* Lookback (N): 50
* Range Mode: True Range (TR) for gap-prone markets; Candle (H–L) for cleaner intraday bars
* Smoothing: On, length 10
* Spike Threshold: 1.5×
* Baseline Length: 200
---
## Notes / Limitations
* This is not a buy/sell signal. It’s a volatility/range context tool.
* Results depend on timeframe. A spike on 1m means something very different than a spike on 1h.
* “Ticks” display uses the symbol’s `mintick` and will be most meaningful on instruments with standardized tick sizes (futures, many FX pairs, etc.).
---
## Invite-Only / Access Copy
This script is published as “Invite-Only.”
If you’ve been granted access, it will appear under Indicators → Invite-only scripts on TradingView.
If you don’t see it, you likely haven’t been added yet—request access from the publisher.
---
Tập lệnh chỉ hiển thị cho người được mời
Chỉ những người dùng được tác giả chấp thuận mới có thể truy cập tập lệnh này. Bạn sẽ cần yêu cầu và được cấp quyền sử dụng. Thông thường quyền này được cấp sau khi thanh toán. Để biết thêm chi tiết, làm theo hướng dẫn của tác giả bên dưới hoặc liên hệ trực tiếp với CoreySurles.
TradingView KHÔNG khuyến nghị bạn trả phí hoặc sử dụng một tập lệnh trừ khi bạn hoàn toàn tin tưởng vào tác giả và hiểu cách hoạt động của tập lệnh. Bạn cũng có thể tìm các lựa chọn miễn phí, mã nguồn mở trong các script cộng đồng của chúng tôi.
Hướng dẫn của tác giả
Thông báo miễn trừ trách nhiệm
Tập lệnh chỉ hiển thị cho người được mời
Chỉ những người dùng được tác giả chấp thuận mới có thể truy cập tập lệnh này. Bạn sẽ cần yêu cầu và được cấp quyền sử dụng. Thông thường quyền này được cấp sau khi thanh toán. Để biết thêm chi tiết, làm theo hướng dẫn của tác giả bên dưới hoặc liên hệ trực tiếp với CoreySurles.
TradingView KHÔNG khuyến nghị bạn trả phí hoặc sử dụng một tập lệnh trừ khi bạn hoàn toàn tin tưởng vào tác giả và hiểu cách hoạt động của tập lệnh. Bạn cũng có thể tìm các lựa chọn miễn phí, mã nguồn mở trong các script cộng đồng của chúng tôi.