Volatility Percentile
Jan 22, 2022

The Volatility Percentile indicator provides a statistical ranking of an instrument's current volatility relative to its historical values using an Average True Range (ATR) based percentile calculation. This tool helps traders determine if the current market environment is experiencing exceptionally high or low volatility compared to its normal distribution, aiding in strategy selection and risk management.
Usage
The Volatility Percentile can be used to adapt trading strategies to current market conditions. Historically, trend-following strategies tend to perform better during periods of low volatility, while mean-reversion or reversal patterns may be more effective during high volatility spikes.
- Percentile Reading: A high percentile (e.g., above 80) indicates that the current ATR is higher than 80% of historical bars, suggesting extreme market activity. Conversely, a low percentile (e.g., below 20) suggests the market is in a compressed or quiet state.
- Statistical Table: The indicator includes a summary table in the bottom right showing the current ATR percentage, the median/maximum historical ATR, and the current percentile rank.
- Detailed Stats: Enabling the detailed statistics view generates a matrix mapping out the historical distribution of volatility, allowing users to see how often specific ATR percentage ranges occur.
- Inverse Mode: Users can toggle the "Inverse" setting to track the percentile with respect to the lowest ATR values instead of the highest.
Details
The script calculates volatility as the ATR expressed as a percentage of the price. To determine the percentile, the script utilizes an array-based counting system that acts as a series of "buckets." Every bar's ATR percentage is rounded and sorted into its respective bucket.
By analyzing the sum of counters in these buckets, the script identifies how many historical bars had a lower, equal, or higher volatility than the current bar. This allows for a precise percentile calculation without needing to store every single historical value individually, maintaining performance while providing a deep historical lookback.
Settings
ATR
- Type: Selects the moving average type used for the ATR calculation (e.g., SMA, EMA, HMA, etc.).
- Length: The lookback period for the ATR calculation.
- Rounding Type: Determines how ATR percentage values are categorized into buckets (Round, Floor, or Ceil).
- Precision: Adjusts the granularity of the volatility buckets. Higher precision (up to 2) provides more detailed percentile readings.
Display
- Inverse: When enabled, the percentile is calculated relative to the lowest historical volatility instead of the highest.
- Stats: Toggles the visibility of the summary statistics table.
- Detailed Stats: Replaces the percentile plot with a comprehensive table showing the full historical distribution of volatility.
Table
- Text Size: Adjusts the size of the text within the tables.
- Header/Cell/Present Colors: Customizes the visual appearance of the table components.
Window
- Start Time / End Time: Allows users to define a specific historical date range for the volatility study instead of analyzing all available historical data.
FAQ
How do I use the Volatility Percentile to filter trades?
Traders often use the percentile to avoid entering trend trades when volatility is at its 90th percentile (exhaustion risk) or to look for breakouts when volatility has been sustained at very low percentiles (compression).
What does "Precision" affect in the settings?
Precision determines how many "buckets" are used to count historical values. A precision of 2 uses 10,000 buckets, providing a very smooth and accurate percentile rank, whereas a precision of 0 uses only 100 buckets.
How can I access this indicator?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.