OPEN-SOURCE SCRIPT
Relative ATR Volatility Indicator

This relative volatility regime indicator measures whether current volatility is high, low, or "normal" compared to its own recent historical range.
It calculates ATR, then compares the current ATR reading against a rolling percentile window. By default, it looks back over the last 100 bars and marks:
With the default settings of a 100-bar Rolling Window Length, Top Percentile of 80, and Bottom Percentile of 20:
If the white ATR line is above the red line, current volatility is in the highest 20% of recent ATR readings.
If the white ATR line is below the green line, current volatility is in the lowest 20% of recent ATR readings.
In other words, the script ranks current ATR against its own recent history and highlights volatility extremes. This makes it easier to objectively identify whether a market is currently in a high-volatility, low-volatility, or normal-volatility regime.
The indicator is directionally agnostic. A high ATR reading does not mean price is bullish or bearish; it simply means the market is moving more than usual. High ATR can occur during bullish expansion, bearish selloffs, large gaps, or choppy high-range conditions.
The main values are:
The ATR Ratio values can be used as an input by other scripts or strategies:
This script uses Pine Script's ta.percentile_nearest_rank() function to calculate rolling ATR percentile thresholds.
This is a lagging indicator, like most indicators, but it provides a useful way to classify volatility regimes objectively.
It calculates ATR, then compares the current ATR reading against a rolling percentile window. By default, it looks back over the last 100 bars and marks:
- The upper volatility threshold, based on the 80th percentile of recent ATR readings (red)
- The lower volatility threshold, based on the 20th percentile of recent ATR readings (green)
With the default settings of a 100-bar Rolling Window Length, Top Percentile of 80, and Bottom Percentile of 20:
If the white ATR line is above the red line, current volatility is in the highest 20% of recent ATR readings.
If the white ATR line is below the green line, current volatility is in the lowest 20% of recent ATR readings.
In other words, the script ranks current ATR against its own recent history and highlights volatility extremes. This makes it easier to objectively identify whether a market is currently in a high-volatility, low-volatility, or normal-volatility regime.
The indicator is directionally agnostic. A high ATR reading does not mean price is bullish or bearish; it simply means the market is moving more than usual. High ATR can occur during bullish expansion, bearish selloffs, large gaps, or choppy high-range conditions.
The main values are:
- White line = current ATR value
- Red line = upper ATR percentile threshold
- Green line = lower ATR percentile threshold
- Grey line = middle 50th percentile (turned off in Style Settings by default)
- ATR Ratio Upper = current ATR divided by the upper threshold
- ATR Ratio Lower = current ATR divided by the lower threshold
The ATR Ratio values can be used as an input by other scripts or strategies:
- ATR Ratio Upper above 1 means ATR is above the upper volatility threshold
- ATR Ratio Lower below 1 means ATR is below the lower volatility threshold
This script uses Pine Script's ta.percentile_nearest_rank() function to calculate rolling ATR percentile thresholds.
This is a lagging indicator, like most indicators, but it provides a useful way to classify volatility regimes objectively.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
My Resources Hub: theartoftrading.com
FREE YouTube Lessons: rebrand.ly/zyt
FREE Pine Script Basics Course: rebrand.ly/zpsbc
Pine Script MASTERY Course: rebrand.ly/zpsmc
My Indicators & Strategies: rebrand.ly/zmisc
FREE YouTube Lessons: rebrand.ly/zyt
FREE Pine Script Basics Course: rebrand.ly/zpsbc
Pine Script MASTERY Course: rebrand.ly/zpsmc
My Indicators & Strategies: rebrand.ly/zmisc
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
My Resources Hub: theartoftrading.com
FREE YouTube Lessons: rebrand.ly/zyt
FREE Pine Script Basics Course: rebrand.ly/zpsbc
Pine Script MASTERY Course: rebrand.ly/zpsmc
My Indicators & Strategies: rebrand.ly/zmisc
FREE YouTube Lessons: rebrand.ly/zyt
FREE Pine Script Basics Course: rebrand.ly/zpsbc
Pine Script MASTERY Course: rebrand.ly/zpsmc
My Indicators & Strategies: rebrand.ly/zmisc
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。