# Volatility Regime Classification

Volatility Regime Classification is an indicator on [Vela](https://vela.luxalgo.com/chart), our next-generation charting platform, written in Pine Script®.

Classifies volatility into Low, Normal, High and Crisis states with boundaries drawn by the data: a rolling k-means on the log of ATR %, realized volatility or Bollinger BandWidth learns where each state starts on this symbol. Hysteresis and confirmation bars keep states stable, and the dashboard reports each state's stay probability, typical run and an inverse-volatility size scale.

- Indicator in the LuxAlgo Library, by LuxAlgo, published May 1, 2026.
- Access: free.
- Concepts: [volatility regime classification](https://www.luxalgo.com/library/concept/volatility-regime-classification/) (primary)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=jmp7y4f6f4inifdodxktnnue
- Page: https://www.luxalgo.com/library/indicator/volatility-regime-classification/

**Volatility Regime Classification** categorizes current market volatility into distinct regimes using dynamic, data-driven thresholds. By applying a one-dimensional k-means clustering approach on chosen volatility measures, it identifies periods of low, normal, high, or crisis-level volatility. This tool helps traders adapt their strategies to different market environments by quantifying the volatility context relative to recent historical performance, rather than relying on arbitrary fixed boundaries that may not apply to every asset.

## How to Trade the Volatility Regime Classification?

Trading based on regimes allows for dynamic position sizing and strategy selection based on the current market environment. In Low volatility regimes, price action is often compressed, which may suggest potential breakout opportunities or the use of range-bound strategies. Conversely, High or Crisis volatility regimes indicate erratic movement where risk management is paramount. During these periods, many traders choose to reduce exposure or tighten stop-loss orders to account for wider price swings. 

The dashboard provides essential statistics on how long regimes typically last and the current persistence of the volatility state, helping traders gauge whether the current environment is likely to continue or if a transition is occurring. Users can monitor the boundaries plotted on the chart to identify structural shifts in market volatility. By observing when the price-based volatility crosses these learned boundaries, you can align your entry and exit criteria with the market's current psychological and structural state.

## Volatility Regime Classification Settings

### Volatility Measure
- **Measure:** Selects between ATR %, Realized Volatility, or Bollinger BandWidth as the source for classification.
- **Length:** Sets the lookback period used for the volatility calculation.
- **Periods per Year:** Adjusts the annualization factor for Realized Volatility based on the market timeframe.

### Data-Drawn Boundaries
- **Training Window:** Defines how many historical bars are used to learn the state boundaries.
- **Minimum History:** Sets the threshold of historical bars required before the first classification fit.
- **Crisis Tier:** Enables a fourth state above the High state to capture extreme market stress.
- **Refit Every:** Controls how frequently the algorithm recalculates boundaries as new data arrives.
- **Passes per Refit:** Adjusts the computational effort used during each cluster update.

### State Stability
- **Hysteresis:** Defines the buffer around boundaries to prevent rapid or unnecessary flipping between states.
- **Confirmation Bars:** Sets the required number of consecutive bars a new state must hold before the indicator officially commits to a switch.

### Style
- **Boundaries:** Toggles the visibility of lines separating the different volatility states.
- **State Background:** Toggles the background tinting for the Low, High and Crisis regimes; the Normal regime is left untinted.
- **State Change Labels:** Displays text markers when the volatility regime transitions.

### Dashboard
- **Show Dashboard:** Enables an on-screen table displaying statistical details about regimes.
- **Detail:** Toggles between showing only the current state or a table for all states.
- **Position/Size:** Adjusts the screen layout and text scale of the dashboard overlay.

## Frequently Asked Questions

### How does the k-means clustering approach benefit my analysis?
Instead of using arbitrary or static thresholds, the indicator learns boundaries directly from the recent history of the asset. This ensures that the classification is always relative to the current market behavior rather than a fixed value that may become irrelevant over time.

### What is the purpose of the Hysteresis setting?
Hysteresis prevents excessive flipping between regimes when volatility is hovering near a boundary. It requires the volatility measure to push deeper into a new regime's range before the indicator commits to a state change, providing a more stable reading.

### Can this indicator be used on any market?
Yes, the indicator is designed to be scale-free and adaptable to various timeframes and asset classes. By adjusting the training window and the volatility measure, it can be calibrated to reflect the specific volatility characteristics of any traded instrument.

## Related indicators

- [Volatility Contraction Pattern](https://www.luxalgo.com/library/indicator/volatility-contraction-pattern/) (Volatility): markdown at https://www.luxalgo.com/library/indicator/volatility-contraction-pattern.md
- [NR4 & NR7 with Breakouts](https://www.luxalgo.com/library/indicator/nr4-nr7-with-breakouts/) (NR4/NR7 Narrow-range Bars): markdown at https://www.luxalgo.com/library/indicator/nr4-nr7-with-breakouts.md
- [Master Pattern](https://www.luxalgo.com/library/indicator/master-pattern/) (Range Expansion/contraction): markdown at https://www.luxalgo.com/library/indicator/master-pattern.md
- [Waddah Attar Explosion](https://www.luxalgo.com/library/indicator/waddah-attar-explosion/) (Volatility): markdown at https://www.luxalgo.com/library/indicator/waddah-attar-explosion.md
- [Squeeze Index](https://www.luxalgo.com/library/indicator/squeeze-index/) (Range Expansion/contraction): markdown at https://www.luxalgo.com/library/indicator/squeeze-index.md
- [Choppiness Index](https://www.luxalgo.com/library/indicator/choppiness-index/) (Volatility): markdown at https://www.luxalgo.com/library/indicator/choppiness-index.md
- [Damiani Volatmeter](https://www.luxalgo.com/library/indicator/damiani-volatmeter/) (Volatility): markdown at https://www.luxalgo.com/library/indicator/damiani-volatmeter.md
- [Volatility Switch](https://www.luxalgo.com/library/indicator/volatility-switch/) (Volatility): markdown at https://www.luxalgo.com/library/indicator/volatility-switch.md

---

Source: https://www.luxalgo.com/library/indicator/volatility-regime-classification/ (LuxAlgo Library). Free to use with attribution: https://www.luxalgo.com/library/license/
