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. اقرأ المزيد في شروط الاستخدام.