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, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.
Скрипт с открытым кодом
В истинном духе TradingView автор этого скрипта опубликовал его с открытым исходным кодом, чтобы трейдеры могли понять, как он работает, и проверить на практике. Вы можете воспользоваться им бесплатно, но повторное использование этого кода в публикации регулируется Правилами поведения.
Отказ от ответственности
Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.