OPEN-SOURCE SCRIPT
Relative Vigor Index with Divergence and SMA Filter

This script implements the Relative Vigor Index (RVI), originally developed by John Ehlers, enhanced with three practical analytical layers:
1. Configurable SMA filter applied to the RVI line (default: 14 periods) to smooth noise and clarify the underlying momentum trend.
2. Automated divergence detection between price action and the RVI oscillator, identifying both:
- Regular divergences ("R"): potential reversal signals (e.g., price makes a lower low while RVI makes a higher low).
- Hidden divergences ("H"): potential continuation signals (e.g., price makes a higher low while RVI makes a lower low).
3.Visual aids: labeled markers ("R"/"H") and connecting lines to make divergence patterns immediately recognizable.
Unlike basic RVI implementations, this version is designed to highlight momentum-price decoupling—a core concept in technical analysis—using robust pivot detection (`ta.pivotlow`/`ta.pivothigh`) with user-defined lookback and search ranges (default: 5–60 bars). The SMA filter helps traders distinguish between genuine momentum shifts and short-term volatility.
How it works:
- The RVI is calculated as the ratio of smoothed (close – open) to smoothed (high – low), reflecting the idea that in uptrends, closes tend to occur near highs, and in downtrends, near lows.
- Divergences are confirmed only when both a valid price pivot and a corresponding RVI pivot occur within the specified bar range.
- Hidden bearish divergences are disabled by default to reduce noise on shorter timeframes.
Suggested use:
- Use regular bullish divergences near negative RVI extremes as potential long setups.
- Watch for regular bearish divergences at positive RVI peaks as early reversal warnings.
- Combine with support/resistance or trend structure for higher-confidence entries.
This script is not a simple mashup: the integration of divergence logic with the RVI’s unique behavior, configurable sensitivity, and clean visualization provides a cohesive analytical tool that goes beyond standard implementations.
> 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.
—
Credits:
- Relative Vigor Index concept: John Ehlers
- Divergence methodology: Standard technical analysis practice
- Implementation and enhancements: © Carlos Mauricio Vizcarra (2025)
- Licensed under MPL 2.0
1. Configurable SMA filter applied to the RVI line (default: 14 periods) to smooth noise and clarify the underlying momentum trend.
2. Automated divergence detection between price action and the RVI oscillator, identifying both:
- Regular divergences ("R"): potential reversal signals (e.g., price makes a lower low while RVI makes a higher low).
- Hidden divergences ("H"): potential continuation signals (e.g., price makes a higher low while RVI makes a lower low).
3.Visual aids: labeled markers ("R"/"H") and connecting lines to make divergence patterns immediately recognizable.
Unlike basic RVI implementations, this version is designed to highlight momentum-price decoupling—a core concept in technical analysis—using robust pivot detection (`ta.pivotlow`/`ta.pivothigh`) with user-defined lookback and search ranges (default: 5–60 bars). The SMA filter helps traders distinguish between genuine momentum shifts and short-term volatility.
How it works:
- The RVI is calculated as the ratio of smoothed (close – open) to smoothed (high – low), reflecting the idea that in uptrends, closes tend to occur near highs, and in downtrends, near lows.
- Divergences are confirmed only when both a valid price pivot and a corresponding RVI pivot occur within the specified bar range.
- Hidden bearish divergences are disabled by default to reduce noise on shorter timeframes.
Suggested use:
- Use regular bullish divergences near negative RVI extremes as potential long setups.
- Watch for regular bearish divergences at positive RVI peaks as early reversal warnings.
- Combine with support/resistance or trend structure for higher-confidence entries.
This script is not a simple mashup: the integration of divergence logic with the RVI’s unique behavior, configurable sensitivity, and clean visualization provides a cohesive analytical tool that goes beyond standard implementations.
> 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.
—
Credits:
- Relative Vigor Index concept: John Ehlers
- Divergence methodology: Standard technical analysis practice
- Implementation and enhancements: © Carlos Mauricio Vizcarra (2025)
- Licensed under MPL 2.0
오픈 소스 스크립트
진정한 트레이딩뷰 정신에 따라 이 스크립트 작성자는 트레이더가 기능을 검토하고 검증할 수 있도록 오픈소스로 공개했습니다. 작성자에게 찬사를 보냅니다! 무료로 사용할 수 있지만 코드를 다시 게시할 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.
오픈 소스 스크립트
진정한 트레이딩뷰 정신에 따라 이 스크립트 작성자는 트레이더가 기능을 검토하고 검증할 수 있도록 오픈소스로 공개했습니다. 작성자에게 찬사를 보냅니다! 무료로 사용할 수 있지만 코드를 다시 게시할 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.