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 อ่านเพิ่มเติมที่ ข้อกำหนดการใช้งาน