Volatility expansion
How much ATR has risen or fallen over the last five bars against the window: above zero means volatility is expanding.
VolatilityExpansion takes the ATR (average true range, a per-bar measure of how far price moves) from its input, by default the basic ATR indicator at default settings. It keeps the last lookback ATR values and, once that window is full, compares the average of the most recent five with the average of the older values in the window. The output is that difference as a fraction of the older average: positive when volatility is expanding, negative when it is contracting.
How to read it
- The line sits in its own pane below the price; zero means ATR is steady across the window.
- Above about +0.4 volatility is expanding fast, roughly the top 5% of readings on SPY one-minute bars.
- Below about -0.3 volatility is contracting; the 5th percentile on the same bars is -0.28.
- Read the typical band of about -0.3 to +0.5 rather than single spikes.
What it outputs
- Volatility expansion
- Change in ATR over the last five bars against the older part of the window: 0 is steady, above 0 is rising volatility, below 0 is falling.
Settings
- lookback
- Number of ATR values kept. Longer windows give a slower baseline, so only large volatility shifts move the line far from zero. Shorter windows react fast but swing on noise. Keep it at 6 or more: 1 to 4 always read 0, and 5 raises an error.
Pitfalls
- It measures volatility, not direction: a rising reading says ATR is growing, not which way price will move. The description calls it a precursor to explosive moves, but the code only compares past ATR values.
- The ratio becomes very large when the older average is near zero; the sample max is 16.5 against a 5th to 95th percentile band of -0.28 to +0.47, so one huge bar can dominate a view.
- The first lookback bars read 0 while the window fills, which looks calm but is warm-up. Lookback 1 to 4 always reads 0, and 5 raises a division-by-zero error in the reference code.