Relative Vigor Index on TradingView
The Relative Vigor Index (RVI or RVGI) divides smoothed close-minus-open movement by smoothed high-minus-low range. Its signal line smooths the resulting ratio. Use the formula, worked numbers, and Pine Script below to check each stage before turning a crossover into a trading rule.
Signal = SWMA(RVI)
This is the price-vigor indicator. Relative Volatility Index is a separate indicator with the same RVI abbreviation.
The formula has two smoothing stages
For a series x, the four-bar filter is W(x) = (x + 2x[1] + 2x[2] + x[3]) / 6. Apply it separately to candle bodies and ranges; sum each over N bars, then divide. Applying the filter to each bar's body/range ratio would produce a different indicator.
TradingView's formula uses a ratio of N-period simple averages. The code uses sums: their identical division by N cancels. The signal is W(RVI), so changing N does not change its four-bar window. See TradingView's formula diagram.
A small range alone cannot make valid RVI values grow without limit. A zero denominator is a different case: all contributing ranges are zero, so the ratio is undefined. The script returns na instead of inventing a neutral reading.
Worked example: from eight bars to one signal
This is a hypothetical arithmetic check, not market data or a backtest. All eight bars open at 100, have a high of 104 and a low of 98; only the close changes. Set N = 2 to keep the full calculation short. Values below are rounded to six decimals.
| Bar | Close | C − O | W(C − O) | RVI, N = 2 | Signal |
|---|---|---|---|---|---|
| 1 | 101 | 1 | na | na | na |
| 2 | 102 | 2 | na | na | na |
| 3 | 99 | −1 | na | na | na |
| 4 | 103 | 3 | 1.000000 | na | na |
| 5 | 102 | 2 | 1.333333 | 0.194444 | na |
| 6 | 100 | 0 | 1.500000 | 0.236111 | na |
| 7 | 99 | −1 | 1.000000 | 0.208333 | na |
| 8 | 101 | 1 | 0.166667 | 0.097222 | 0.196759 |
On bar 5, W(C − O) = (2 + 2×3 + 2×(−1) + 2) / 6 = 4/3. Its two-bar numerator is 1 + 4/3 = 7/3; the denominator is 6 + 6 = 12. Thus RVI = 7/36 = 0.194444.
On bar 8, signal = (7/72 + 2×5/24 + 2×17/72 + 7/36) / 6 = 85/432 = 0.196759. RVI is below its signal, but this is the first valid signal value. A crossover needs a previous valid pair, so the script does not mark a down cross on bar 8.
Pine Script v6: RVI with confirmed crossover alerts
The copyable indicator keeps the component formula used by Pineify's RVI implementation, adds an editable length, and makes the zero-denominator policy explicit. Blue is RVI; orange is the signal. Up/down triangles mark closed-bar crosses, not trade orders.
//@version=6
indicator("Relative Vigor Index: confirmed crosses", overlay = false)
length = input.int(10, "RVI length", minval = 1)
// Smooth each component before summing, then divide.
numerator = math.sum(ta.swma(close - open), length)
denominator = math.sum(ta.swma(high - low), length)
rvi = not na(denominator) and denominator > 0 ? numerator / denominator : na
signal = ta.swma(rvi)
plot(rvi, "RVI", color = color.blue, linewidth = 2, style = plot.style_linebr)
plot(signal, "Signal", color = color.orange, linewidth = 2, style = plot.style_linebr)
hline(0, "Zero", color = color.gray)
// Evaluate crosses on every bar; mark and alert only at the close.
crossUp = ta.crossover(rvi, signal)
crossDown = ta.crossunder(rvi, signal)
confirmedUp = crossUp and barstate.isconfirmed
confirmedDown = crossDown and barstate.isconfirmed
plotshape(confirmedUp, "Confirmed up cross", shape.triangleup, location.bottom, color.blue, size = size.tiny)
plotshape(confirmedDown, "Confirmed down cross", shape.triangledown, location.top, color.orange, size = size.tiny)
alertcondition(confirmedUp, "RVI above signal", "RVI crossed above its signal line on a closed bar.")
alertcondition(confirmedDown, "RVI below signal", "RVI crossed below its signal line on a closed bar.")Paste into a new Pine Editor indicator, save, then add it to the chart. Add TradingView's built-in Relative Vigor Index with matching length and compare closed bars in the Data Window. Use standard candles, the same symbol and session, and identical history before diagnosing a difference.
With complete data and N = 10, the first ratio needs 13 bars and the first signal needs 16. That follows from the initial four-bar filter, ten valid filtered observations, and four valid ratios for the signal. Missing input data or zero denominators can delay usable values.
Settings, confirmation, and signal meaning
| Setting or observation | What it changes or means |
|---|---|
| Length = 10 | The example default matches Pineify's configuration. It counts chart bars, so 10 hourly bars and 10 daily bars cover different periods. |
| Shorter or longer length | Changes the component sum window. Compare responsiveness on fixed data; no length is established here as optimal. |
| RVI above zero | The weighted net close-minus-open movement is positive. It does not mean the numerator exceeds the range denominator. |
| RVI above signal | RVI is above its weighted recent average. Both lines can still be below zero. |
| Confirmed up cross | The current RVI is above signal and the previous RVI was at or below signal, on a closed bar with valid values. |
| Price/indicator divergence | Different price and oscillator swing directions require explicit pivot and confirmation rules; this code does not detect divergence. |
The live lines still update during an open candle. barstate.isconfirmed gates only the markers and alert conditions in this example. TradingView's bar-state documentation describes this closing-update behavior. Select the desired condition when creating an alert; the code alone does not create an active alert.
Failure modes to check before testing a strategy
- Flat windows: a single flat candle can coexist with earlier nonzero ranges. Check the entire denominator before treating zero-range data as an error. Keep undefined values visible as gaps.
- Gaps between sessions: a close of 101 after an open of 100 contributes +1 even if the previous close was 110. The indicator describes that bar's body, so positive RVI can accompany a larger price decline across sessions.
- Frequent crosses: nearby lines can cross repeatedly in a narrow range. Count crossings under a fixed rule before adding filters; a smoother-looking line alone is not evidence of trading value.
- Timing assumptions: a signal after the close does not imply a fill at that close. Specify order execution, exits, position size, fees, and slippage separately in a strategy.
- Chart inputs: changing sessions, timeframe, feed, or candle construction changes OHLC and therefore the result. Validate the input bars as well as the formula.
This is an indicator implementation and arithmetic example for education, not investment advice. It contains no measured win rate, profitability claim, or recommended trade.
Relative Vigor Index versus Relative Volatility Index
The shared abbreviation is a naming collision. TradingView's Relative Volatility Index is based on standard deviation and uses a 0-to-100 scale. A level of 50 belongs to that scale, not to the unscaled vigor ratio shown here.
| Indicator | Input comparison | Reference level |
|---|---|---|
| Relative Vigor Index | Close − open versus high − low | Zero |
| Relative Volatility Index | Directional price standard deviation | 50 on a 0-to-100 scale |
Turn a checked formula into a Pineify request
Pineify's Pine Script AI Coding Agent can help draft or revise a script from a written specification. Give it a calculation and a verification target before requesting strategy logic.
Create a Relative Vigor Index indicator in Pine Script v6. Use length 10, the 1:2:2:1 four-bar filter on close minus open and high minus low, and a four-bar weighted signal. Return na for a zero denominator. Confirm crossover alerts at bar close. Keep it on the chart timeframe and expose both intermediate sums in the Data Window for comparison.
- Open the Coding Agent and provide the specification plus this example.
- Inspect the generated inputs, denominator policy, and alert timing.
- Compile in TradingView and compare values bar by bar, including flat windows.
- Define exits and execution costs separately if converting to a strategy.
Frequently asked questions
Sources and related reading
Official sources reviewed on October 17, 2026. The worked table and bounds check are arithmetic demonstrations.