OPEN-SOURCE SCRIPT
RVI with SMA Smoothing and Divergence Signals

This script enhances the Relative Volatility Index (RVI)—originally introduced by Donald Dorsey in 1993—by integrating three complementary analytical features:
1. SMA-based smoothing of the RVI line to reduce noise and clarify the underlying volatility momentum trend.
2. Automated detection of regular and hidden divergences between price action (highs/lows) and RVI pivots, using robust `ta.pivotlow` and `ta.pivothigh` logic with configurable lookback and search ranges.
3. Visual labels ("R" for regular, "H" for hidden) and color-coded pivot markers to help traders quickly identify potential reversal or continuation zones.
Unlike basic RVI implementations, this version is designed to highlight momentum-price decoupling, a key concept in technical analysis. The divergence engine is synchronized with RVI’s unique 0–100 scale and volatility-based calculation, ensuring signals are contextually relevant—not generic overlays.
How it works:
- RVI is computed using standard deviation of directional price changes, normalized to 0–100.
- A user-defined SMA (default: 14 periods) smooths the RVI for trend clarity.
- Divergences are confirmed only when both a valid price pivot and a corresponding RVI pivot occur within a configurable bar range (default: 5–60 bars).
- Hidden bearish divergences are disabled by default to reduce noise on short-term charts.
Suggested use:
- Regular bullish divergences near the 20 (oversold) level may signal exhaustion of a downtrend.
- Regular bearish divergences above 80 (overbought) can warn of upward momentum loss.
- Combine with price structure (support/resistance) for higher-probability setups.
This script is **not a simple mashup**: the integration of divergence logic with RVI’s volatility-based nature, parameterized sensitivity controls, and clean visualization provides a cohesive analytical tool not found in standard indicators.
> Disclaimer: This script is for educational and informational purposes only. It does not constitute financial, investment, or trading advice. Past performance is not indicative of future results.
—
Créditos:
- RVI concept: Donald Dorsey (1993)
- Divergence methodology: Standard technical analysis practice
- Implementation and enhancements: © Carlos Mauricio Vizcarra (2025)
- Licensed under MPL 2.0
1. SMA-based smoothing of the RVI line to reduce noise and clarify the underlying volatility momentum trend.
2. Automated detection of regular and hidden divergences between price action (highs/lows) and RVI pivots, using robust `ta.pivotlow` and `ta.pivothigh` logic with configurable lookback and search ranges.
3. Visual labels ("R" for regular, "H" for hidden) and color-coded pivot markers to help traders quickly identify potential reversal or continuation zones.
Unlike basic RVI implementations, this version is designed to highlight momentum-price decoupling, a key concept in technical analysis. The divergence engine is synchronized with RVI’s unique 0–100 scale and volatility-based calculation, ensuring signals are contextually relevant—not generic overlays.
How it works:
- RVI is computed using standard deviation of directional price changes, normalized to 0–100.
- A user-defined SMA (default: 14 periods) smooths the RVI for trend clarity.
- Divergences are confirmed only when both a valid price pivot and a corresponding RVI pivot occur within a configurable bar range (default: 5–60 bars).
- Hidden bearish divergences are disabled by default to reduce noise on short-term charts.
Suggested use:
- Regular bullish divergences near the 20 (oversold) level may signal exhaustion of a downtrend.
- Regular bearish divergences above 80 (overbought) can warn of upward momentum loss.
- Combine with price structure (support/resistance) for higher-probability setups.
This script is **not a simple mashup**: the integration of divergence logic with RVI’s volatility-based nature, parameterized sensitivity controls, and clean visualization provides a cohesive analytical tool not found in standard indicators.
> Disclaimer: This script is for educational and informational purposes only. It does not constitute financial, investment, or trading advice. Past performance is not indicative of future results.
—
Créditos:
- RVI concept: Donald Dorsey (1993)
- Divergence methodology: Standard technical analysis practice
- Implementation and enhancements: © Carlos Mauricio Vizcarra (2025)
- Licensed under MPL 2.0
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.