Volatility regime detector
Volatility regime on each bar: 0 calm, 1 normal, 2 busy, judged against its own recent average.
The indicator reads two volatility measures on each bar: the average true range (ATR, smoothed with length atr_window), and the standard deviation of one-bar price changes over window bars. Each is divided by its own average over the last window bars, and that average includes the current bar. The regime is 2 if either ratio is above 1.5, 0 only if both are below 0.7, and 1 otherwise.
How to read it
- The line sits in its own pane below the price and only takes the whole values 0, 1 and 2.
- 1 is the usual reading and the median of the sample. 2 means the current ATR or price-change spread is more than 1.5 times its recent average.
- 0 means both measures are under 0.7 times their average. On the sample it covers under about 5% of bars, so a 0 marks a notably quiet stretch.
- A move into 2 marks a busier stretch, not a direction. Use the line as backdrop for the price action, not as an entry signal.
What it outputs
- Volatility regime
- Whole-number regime: 0 low, 1 normal, 2 high volatility. Blank at the start while the averages fill.
Settings
- window
- Bars in the baseline average. Shorter (5 to 10) swings the regime between 1 and 2 more, and a long busy stretch fades back to 1 as the average catches up. Longer (60+) steadies the baseline. At 1 the baseline is the bar itself, so the regime is meaningless.
- atr_window
- Smoothing length of the average true range. Shorter (5) lets one very wide bar push the regime to 2 at once. Longer (30+) needs a sustained wider range to reach 2 and reacts slowly.
Pitfalls
- The regime is relative to recent history, not absolute size. A busy session reads 1 once the average catches up, so a 1 does not mean quiet and a 2 does not mean an extreme move.
- The indicator only reads the close, high and low it is wired to. On a SPY chart it measures SPY volatility.
- The 1.5 and 0.7 thresholds are fixed in the code, so window and atr_window are the only levers.