Relative Volume vs N-Day Average
This indicator compares the current bar's volume to the simple average of volume over a lookback period, expressed as a ratio. A reading above 1.0 signals above-average volume; below 1.0 signals below-average volume. Traders use it to identify when price moves are accompanied by conviction (rising price on high relative volume) or potential weakness (price reversals on low relative volume), and to filter entry signals based on volume participation. The tool also helps spot institutional accumulation or distribution patterns by isolating volume spikes from the noise of daily variation.
//@version=6
indicator("Relative Volume vs N-Day Average", shorttitle="Rel Vol Avg", overlay=false)
// Inputs
lengthLookback = input.int(20, title="Lookback Period (days)", minval=2)
showThreshold = input.bool(true, title="Show 1.0 Reference Line")
colorAbove = input.color(color.new(color.green, 20), title="Color Above Average")
colorBelow = input.color(color.new(color.red, 20), title="Color Below Average")
// Calculations
avgVol = ta.sma(volume, lengthLookback)
relVol = avgVol > 0 ? volume / avgVol : 0
// Plots
barColor = relVol >= 1.0 ? colorAbove : colorBelow
plot(relVol, title="Relative Volume", color=barColor, style=plot.style_columns, linewidth=2)
// Reference line at 1.0
if showThreshold
hline(1.0, title="Average Volume (1.0)", color=color.gray, linestyle=hline.style_dashed, linewidth=1)
// Optional label for current value
var float lastVal = na
lastVal := relVol
plotchar(na, title="Value Label", char="", location=location.top)
How the code works
The indicator first accepts a lookback period (default 20 bars) and optional styling inputs. It computes avgVol, the simple moving average of volume over that period using ta.sma(). At each bar, it divides the current bar's volume by avgVol to produce the relVol ratio. A result of 1.5 means volume is 50% above the average; 0.6 means 40% below. The code guards against division by zero with a conditional check. The plot displays this ratio as a column chart, with bars colored green when relative volume exceeds 1.0 and red when it falls short. An optional horizontal dashed line at 1.0 anchors the visual reference. No lookahead or repainting constructs are used; all calculations use only historical data available at each bar.
Reading it on a chart
The indicator appears in a separate panel below price. Tall green columns indicate bars where volume exceeded the N-day average, often corresponding to strong trending moves or breakout attempts. Short red columns show low-conviction trading. A trader might look for confluences: price breaking a resistance level with a relative volume reading above 1.5 signals potential follow-through, while a reversal from an intraday high on a red bar (relative volume below 1.0) hints at weak convict and possible trap. The dashed reference line at 1.0 makes this threshold instantly visible. Rapid switches between green and red can indicate a choppy, poorly committed market; sustained elevation above 1.0 often appears during strong directional runs. Conversely, a breakdown in price paired with a low relative volume reading may suggest capitulation or a false breakdown that reverses quickly.
Limitations
The indicator relies entirely on historical averages and ignores structural changes in market participation. A stock that doubles its average trading volume overnight (e.g., after an earnings announcement) will show initially low relative readings until the new baseline incorporates the shift, creating false negatives during the transition. Raw volume data can differ materially across venues (tick volume on retail platforms vs. true traded contracts on exchange data feeds), so indicator values are not portable across data sources without rescaling. The indicator offers no predictive edge: above-average volume can accompany both capitulation lows and breakout highs, depending entirely on price action context. It also assumes that volume distribution is roughly stable across the lookback period; in markets with structural shifts (e.g., a shift to options instead of equities for hedging), the historical average may misrepresent current participation norms. Finally, the raw ratio form can be hard to interpret without domain knowledge: a reading of 1.8 does not guarantee the move will continue, and low readings do not predict reversals. Traders must combine this with price structure, support/resistance levels, and order-flow context to extract actionable signals.
Key definitions
Relative volume: the ratio of current bar volume to the average volume over a specified historical period; a reading above 1.0 indicates above-average participation.
Simple moving average (SMA): the arithmetic mean of volume (or any value) over a fixed number of bars, updated one bar per close.
Lookback period: the number of historical bars over which the average is computed; longer periods smooth day-to-day noise but lag structural shifts in trading volume.
Confirmation: the alignment of price action (breakout, reversal) with elevated volume, suggesting trader commitment to the directional move.
Trap: a price break beyond a key level that fails to sustain, often accompanied by volume that declines as retail participants chase and institutional players liquidate.
Conviction: the strength of participant commitment to a price move, inferred from volume size and consistency.
References
- Investopedia, "Volume", Investopedia (n.d.). URL: https://www.investopedia.com/terms/v/volume.asp
- CME Group, "Volume and Open Interest", CME Education (n.d.). URL: https://www.cmegroup.com/education/courses/introduction-to-futures/volume-and-open-interest.html
- TradingView, "Pine Script Reference Manual v6", TradingView (2024). URL: https://www.tradingview.com/pine-script-docs/
- John J. Murphy, "Technical Analysis of the Financial Markets", Prentice Hall (1999).
- Wilder, J. Welles, "New Concepts in Technical Trading Systems", Trend Research (1978).
Educational research on historical data only. Not investment advice, not a signal, and never a performance promise. Past results do not predict future performance. Every reference is link-verified before publication and every paper is re-audited weekly against the library's editorial standard.
Last reviewed by the PropLedger research pipeline: 2026-08-30. Educational research on historical data, not financial advice.