What is Volume-Adjusted RSI (VARSI)?
Volume-Adjusted RSI (VARSI) is an adaptation of the popular Relative Strength Index (RSI) that aims to improve its reliability by incorporating volume. While the traditional RSI only considers the magnitude of price changes, VARSI weights these price changes by their associated trading volume. The core idea is that price movements backed by higher volume are more significant and should have a greater impact on the momentum calculation than price movements on lower volume.
By integrating volume, VARSI seeks to filter out "weak" momentum signals that occur on low trading activity and to emphasize "strong" momentum signals that are supported by substantial market participation. This can lead to:
- More robust overbought/oversold readings: VARSI might stay in overbought/oversold territory longer or reach it more decisively when volume confirms the move.
- Stronger divergence signals: Divergences between price and VARSI gain more credibility when the volume component underscores the lack of conviction.
- Enhanced trend confirmation: Momentum supported by volume is considered more sustainable.
In Pine Script, implementing VARSI requires a custom calculation, as it's not a built-in indicator, but it leverages Pine Script's powerful functions for RSI-like smoothing and volume data.
Components and Calculation
The calculation of Volume-Adjusted RSI builds upon the traditional RSI formula by introducing a volume weighting step. Here's a breakdown:
- Price Change Calculation: * `Up_Change = max(close - close[1], 0)` (positive price difference, 0 if negative) * `Down_Change = max(close[1] - close, 0)` (positive price difference on down days, 0 if up)
- Volume-Adjusted Price Change: Each price change is multiplied by the current bar's volume. * `Volume_Adj_Up = Up_Change * volume` * `Volume_Adj_Down = Down_Change * volume`
- Average Volume-Adjusted Gains and Losses: These volume-adjusted changes are smoothed using a Reinforced Moving Average (`ta.rma`), similar to how RSI smooths its gains and losses. * `Avg_Gain_Vol_Adj = ta.rma(Volume_Adj_Up, Length)` * `Avg_Loss_Vol_Adj = ta.rma(Volume_Adj_Down, Length)` (Where `Length` is the RSI period, typically 14)
- Volume-Adjusted Relative Strength (VARS): This is the ratio of the average volume-adjusted gain to the average volume-adjusted loss. * `VARS = Avg_Gain_Vol_Adj / Avg_Loss_Vol_Adj` * Important: Handle division by zero. If `Avg_Loss_Vol_Adj` is 0: * If `Avg_Gain_Vol_Adj` is also 0, `VARS` is indeterminate (can default to 0 or 1). * If `Avg_Gain_Vol_Adj` is > 0, `VARS` is considered infinite (leading to VARSI = 100).
- Volume-Adjusted RSI (VARSI): The final VARSI value is calculated using the standard RSI formula:
`VARSI = 100 - (100 / (1 + VARS))`
The `Length` parameter is typically 14, mirroring the default RSI period.
Basic Volume-Adjusted RSI (VARSI) Implementation in Pine Script
Implementing VARSI in Pine Script involves a custom calculation leveraging `ta.rma()` and careful handling of potential division by zero.
//@version=5
indicator("My Volume-Adjusted RSI (VARSI)", overlay=false) // overlay=false to plot in a separate pane
// Input for VARSI length (smoothing period, similar to standard RSI)
length = input.int(14, title="VARSI Length", minval=1)
// Calculate price changes
up_change = math.max(close - close[1], 0)
down_change = math.max(close[1] - close, 0)
// Calculate volume-adjusted price changes
volume_adj_up = up_change * volume
volume_adj_down = down_change * volume
// Calculate average volume-adjusted gains and losses using RMA (Wilder's smoothing)
avg_gain_vol_adj = ta.rma(volume_adj_up, length)
avg_loss_vol_adj = ta.rma(volume_adj_down, length)
// Calculate Volume-Adjusted Relative Strength (VARS)
// Handle division by zero for avg_loss_vol_adj
vars = if avg_loss_vol_adj != 0
avg_gain_vol_adj / avg_loss_vol_adj
else
if avg_gain_vol_adj > 0
1000000000.0
else
1.0
// Calculate Volume-Adjusted RSI (VARSI)
v_rsi = 100 - (100 / (1 + vars))
// Plot the VARSI line
plot(v_rsi, title="Volume-Adjusted RSI", color=color.blue, linewidth=2)
// Plot standard RSI levels
hline(70, "Overbought", color=color.red, linestyle=hline.style_dashed)
hline(30, "Oversold", color=color.green, linestyle=hline.style_dashed)
hline(50, "Mid-Line", color=color.gray, linestyle=hline.style_dotted)
// Highlight overbought/oversold zones for clarity
bgcolor(v_rsi > 70 ? color.new(color.red, 90) : na, title="Overbought Zone")
bgcolor(v_rsi < 30 ? color.new(color.green, 90) : na, title="Oversold Zone")
Practical Volume-Adjusted RSI (VARSI) Trading Strategies
1. Overbought/Oversold Signals with Volume Conviction
VARSI can be used in a similar way to traditional RSI for identifying potential reversal points, but with the added confidence that the extreme readings are backed by significant volume.
- Sell Signal (Overbought): VARSI moves into overbought territory (e.g., above 70) and then turns down. This suggests that the buying pressure, even when volume-adjusted, is becoming unsustainable.
- Buy Signal (Oversold): VARSI moves into oversold territory (e.g., below 30) and then turns up. This suggests that the selling pressure, even when volume-adjusted, is exhausting.
//@version=5
strategy("VARSI Overbought/Oversold Strategy", overlay=true)
length = input.int(14, title="VARSI Length", minval=1)
obLevel = input.int(70, title="Overbought Level", minval=50, maxval=90)
osLevel = input.int(30, title="Oversold Level", minval=10, maxval=50)
up_change = math.max(close - close[1], 0)
down_change = math.max(close[1] - close, 0)
volume_adj_up = up_change * volume
volume_adj_down = down_change * volume
avg_gain_vol_adj = ta.rma(volume_adj_up, length)
avg_loss_vol_adj = ta.rma(volume_adj_down, length)
vars = if avg_loss_vol_adj != 0
avg_gain_vol_adj / avg_loss_vol_adj
else if avg_gain_vol_adj > 0
1000000000.0
else
1.0
v_rsi = 100 - (100 / (1 + vars))
plot(v_rsi, "VARSI", color=color.blue, display=display.pane_only)
hline(obLevel, "Overbought", color=color.red, linestyle=hline.style_dashed, display=display.pane_only)
hline(osLevel, "Oversold", color=color.green, linestyle=hline.style_dashed, display=display.pane_only)
// Long entry: VARSI crosses above oversold level
longCondition = ta.crossover(v_rsi, osLevel)
// Short entry: VARSI crosses below overbought level
shortCondition = ta.crossunder(v_rsi, obLevel)
if (longCondition)
strategy.entry("Long VARSI", strategy.long)
if (shortCondition)
strategy.entry("Short VARSI", strategy.short)
// Basic exit: opposite signal
strategy.close("Long VARSI", when=shortCondition)
strategy.close("Short VARSI", when=longCondition)
2. Divergence (Enhanced Reversal Signal)
Divergence between price and VARSI is a particularly strong signal, as it indicates a disconnect between price action and the underlying volume-weighted momentum. This adds conviction to the potential for a trend reversal.
- Bullish Divergence: Price makes a lower low, but VARSI makes a higher low (or fails to make a significantly lower low). This implies that despite falling prices, the volume-adjusted selling momentum is weakening, hinting at an upward reversal.
- Bearish Divergence: Price makes a higher high, but VARSI makes a lower high (or fails to make a significantly higher high). This implies that despite rising prices, the volume-adjusted buying momentum is weakening, hinting at a downward reversal.
//@version=5
strategy("VARSI Divergence Strategy", overlay=true)
length = input.int(14, title="VARSI Length", minval=1)
up_change = math.max(close - close[1], 0)
down_change = math.max(close[1] - close, 0)
volume_adj_up = up_change * volume
volume_adj_down = down_change * volume
avg_gain_vol_adj = ta.rma(volume_adj_up, length)
avg_loss_vol_adj = ta.rma(volume_adj_down, length)
vars = if avg_loss_vol_adj != 0
avg_gain_vol_adj / avg_loss_vol_adj
else if avg_gain_vol_adj > 0
1000000000.0
else
1.0
v_rsi = 100 - (100 / (1 + vars))
plot(v_rsi, "VARSI", color=color.blue, display=display.pane_only)
hline(70, "Overbought", color=color.red, linestyle=hline.style_dashed, display=display.pane_only)
hline(30, "Oversold", color=color.green, linestyle=hline.style_dashed, display=display.pane_only)
// Simple divergence detection (conceptual, robust detection requires advanced pivot logic)
// This example looks for recent higher/lower swings in price and VARSI.
// Bullish Divergence: Price lower low, VARSI higher low
bullishDiv = close < close[1] and close[1] < close[2] and v_rsi > v_rsi[1] and v_rsi[1] > v_rsi[2]
// Bearish Divergence: Price higher high, VARSI lower high
bearishDiv = close > close[1] and close[1] > close[2] and v_rsi < v_rsi[1] and v_rsi[1] < v_rsi[2]
// Plot shapes on the chart to indicate divergence
plotshape(bullishDiv, title="Bullish VARSI Divergence", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(bearishDiv, title="Bearish VARSI Divergence", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
if (bullishDiv)
strategy.entry("Long Divergence", strategy.long)
if (bearishDiv)
strategy.entry("Short Divergence", strategy.short)
// Basic exit after a few bars or on opposite signal
strategy.exit("Long Divergence Exit", from_entry="Long Divergence", profit=close*0.02, loss=close*0.01)
strategy.exit("Short Divergence Exit", from_entry="Short Divergence", profit=close*0.02, loss=close*0.01)
3. Trend Confirmation with VARSI's Mid-Line
Similar to standard RSI, VARSI can be used to confirm the prevailing trend. Its mid-line (50 level) acts as a key separator between bullish and bearish momentum backed by volume.
- Uptrend Confirmation: VARSI consistently stays above the 50 level. This suggests that volume-adjusted buying momentum is dominant, confirming an uptrend.
- Downtrend Confirmation: VARSI consistently stays below the 50 level. This suggests that volume-adjusted selling momentum is dominant, confirming a downtrend.
- Mid-Line Crossover: A crossover of the 50 level can signal a shift in the prevailing volume-adjusted momentum bias.
//@version=5
strategy("VARSI Mid-Line Trend Strategy", overlay=true)
length = input.int(14, title="VARSI Length", minval=1)
up_change = math.max(close - close[1], 0)
down_change = math.max(close[1] - close, 0)
volume_adj_up = up_change * volume
volume_adj_down = down_change * volume
avg_gain_vol_adj = ta.rma(volume_adj_up, length)
avg_loss_vol_adj = ta.rma(volume_adj_down, length)
vars = if avg_loss_vol_adj != 0
avg_gain_vol_adj / avg_loss_vol_adj
else if avg_gain_vol_adj > 0
1000000000.0
else
1.0
v_rsi = 100 - (100 / (1 + vars))
plot(v_rsi, "VARSI", color=color.blue, display=display.pane_only)
hline(50, "Mid-Line", color=color.gray, linestyle=hline.style_dotted, linewidth=2, display=display.pane_only)
// Long entry: VARSI crosses above 50
longCondition = ta.crossover(v_rsi, 50)
// Short entry: VARSI crosses below 50
shortCondition = ta.crossunder(v_rsi, 50)
if (longCondition)
strategy.entry("Long Mid-Line", strategy.long)
if (shortCondition)
strategy.entry("Short Mid-Line", strategy.short)
// Basic exit: opposite signal
strategy.close("Long Mid-Line", when=shortCondition)
strategy.close("Short Mid-Line", when=longCondition)
// Color background based on VARSI's position relative to 50
bgcolor(v_rsi > 50 ? color.new(color.lime, 95) : na, title="Bullish Momentum")
bgcolor(v_rsi < 50 ? color.new(color.maroon, 95) : na, title="Bearish Momentum")
Optimizing Volume-Adjusted RSI (VARSI) Performance
To get the most from Volume-Adjusted RSI in Pine Script:
- Parameter Tuning: The `length` parameter (commonly 14) directly impacts VARSI's sensitivity. Shorter lengths make it more reactive but potentially noisy. Longer lengths provide a smoother reading but with more lag. Experiment to find a balance for your asset and timeframe.
- Focus on Divergence: VARSI's key strength lies in its ability to confirm divergences with price due to the added volume component. These are often the most powerful and actionable signals.
- Combine with Price Action: Always confirm VARSI signals with price action. An overbought VARSI signal is stronger if price also forms a bearish reversal candlestick pattern or hits a resistance level.
- Volume Data Quality: VARSI's effectiveness is highly dependent on accurate and reliable volume data. Ensure the asset you are trading has consistent volume reporting.
- Adaptive Levels: While 70/30 are standard for RSI, the "overbought" and "oversold" levels for VARSI might need slight adjustment based on the asset's typical behavior and the impact of volume.
- Use as a Filter: VARSI can be used as a filter for other strategies. For example, only take long entries if VARSI is above 50 or showing bullish divergence.
Common Volume-Adjusted RSI (VARSI) Pitfalls
- Lag: Despite being volume-adjusted, VARSI is still a lagging indicator. It will confirm momentum shifts after they have already begun.
- Whipsaws in Choppy Markets: In highly volatile and non-trending (choppy) markets, VARSI can generate frequent crossovers and enter/exit overbought/oversold zones frequently, leading to false signals.
- Volume Data Consistency: If volume data for an asset is inconsistent, sparse, or manipulated, VARSI's readings will be unreliable.
- Not a Standalone Indicator: VARSI provides valuable insights but should never be used in isolation. It works best as a confirming or filtering indicator within a broader trading strategy.
- Interpretation Complexity: For beginners, understanding the nuances of volume-adjusted momentum might be more challenging than a simple price-based RSI.
Conclusion
The Volume-Adjusted RSI (VARSI) is a powerful and insightful momentum oscillator for Pine Script in TradingView. By integrating volume weighting into the traditional RSI calculation, it provides a more robust measure of overbought/oversold conditions, enhances the reliability of divergence signals, and offers a clearer confirmation of price trend conviction. While requiring a custom implementation and careful attention to its unique interpretation, VARSI serves as an excellent tool for traders seeking to validate momentum with underlying volume strength. By understanding its calculation, thoughtfully tuning its parameters, and integrating it strategically with price action and other technical analysis tools, you can leverage VARSI to significantly enhance your pine script strategies and gain a deeper understanding of true market strength.