The Relative Volatility Index (RVI) is a technical indicator designed to measure the direction and magnitude of volatility. Unlike other volatility indicators that focus solely on the level of price fluctuations (such as Bollinger Bands or ATR), the RVI incorporates the trend direction, making it a valuable tool for identifying potential trade opportunities.
Developed in 1993 by Donald Dorsey, the RVI is often used in combination with trend-following indicators to confirm signals. It resembles the Relative Strength Index (RSI) but instead of measuring price momentum, it focuses on volatility direction.
The RVI is calculated based on the standard deviation of price changes, smoothed over a predefined period. Here’s the step-by-step process:
Standard Deviation Calculation:
Directional Volatility Components:
Smoothing the RVI:
The formula for the RVI is:
Values range from 0 to 100, where higher values indicate stronger upward volatility, and lower values signal downward volatility.
The RVI can be customized using several key parameters:
The RVI is commonly used to confirm trend strength and identify potential reversals:
Trend Confirmation:
Overbought/Oversold Signals:
Divergences:
RVI + Moving Average:
RVI + Bollinger Bands:
Breakout Confirmation:
The RVI can be programmed in ProRealTime’s ProBuilder language, ensuring flexibility in customization. The implementation follows these key steps:
The ProBuilder code follows these principles and allows easy parameter adjustments.
//------------------------------------------------------//
//PRC_RVI relative volatility Index
//version = 0
//06.02.2025
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//------------------------------------------------------//
// Inputs
//------------------------------------------------------//
stdevLength=10
stdevType=1 //boolean variable 1 means Population
smoothLength=14
obLevel=80
mdLevel=50
osLevel=20
highlightBreakouts=1 //boolean variable
maTypeInput=0
maLengthInput=14
useBB=1
bbMultInput=2
src=close
//------------------------------------------------------//
// Standard deviation calculation
//------------------------------------------------------//
//Type=1 Population else Sample
if stdevType=1 then
selectedStdev=STD[stdevLength](src)
else
dev=src-average[stdevLength](src)
variance=summation[stdevLength](pow(dev,2))/(stdevLength-1)
selectedStdev=sqrt(variance)
endif
//------------------------------------------------------//
// RVI original version (1993)
//------------------------------------------------------//
up=(src>=src[1])*selectedStdev
down=(src<src[1])*selectedStdev
upsum=average[smoothLength,1](up)
downsum=average[smoothLength,1](down)
rvi=100*upsum/(upsum+downsum)
//------------------------------------------------------//
// Moving average
//------------------------------------------------------//
maRVI=average[maLengthInput,maTypeInput](rvi)
if useBB then
bbUpperband=maRVI+std[maLengthInput](rvi)*bbMultInput
bbLowerband=maRVI-std[maLengthInput](rvi)*bbMultInput
endif
//------------------------------------------------------//
// Plot
//------------------------------------------------------//
//---Rvi color
if rvi>oblevel then
r=14
g=187
b=35
elsif rvi<oslevel then
r=255
g=0
b=0
else
r=244
g=183
b=125
endif
//---HighlightBreakouts
if rvi>oblevel and highlightBreakouts then
rob=0
gob=255
alphaob=40
else
alphaob=0
endif
if rvi<oslevel and highlightBreakouts then
ros=255
gos=0
alphaos=40
else
alphaos=0
endif
colorbetween(100,oblevel,rob,gob,0,alphaob)
colorbetween(0,oslevel,ros,gos,0,alphaos)
//------------------------------------------------------//
return rvi as "RVI" coloured(r,g,b)style(line,2),maRVI as "MA RVI"coloured("blue"), oblevel as "Overbought Level"coloured("black")style(dottedline),oslevel as "Oversold Level"coloured("black")style(dottedline),mdLevel as "MidLevel" coloured("black")style(dottedline),bbUpperband as "BBUp"coloured("blue")style(dottedline),bbLowerband as "BBDn"coloured("blue")style(dottedline)
The Relative Volatility Index (RVI) is a powerful tool that provides insight into the direction of volatility, helping traders confirm trends and identify reversals. While it should not be used in isolation, combining it with moving averages, Bollinger Bands, or other momentum indicators can enhance its effectiveness.