Volume
Relative Volume
Volume as a multiple of its own recent average, which makes participation comparable across instruments and across times of day instead of an unreadable raw number.
indicator
//@version=6
indicator("Relative Volume", "RVOL")
length = input.int(20, "Average length", minval = 1, group = "Settings")
threshold = input.float(2.0, "Notable multiple", minval = 1, step = 0.1, group = "Settings")
hot = input.color(#26A69A, "At or above threshold", group = "Style")
cool = input.color(#787B86, "Normal", group = "Style")
avgVol = ta.sma(volume, length)
rvol = avgVol > 0 ? volume / avgVol : 0
notable = rvol >= threshold
plot(rvol, "Relative volume", style = plot.style_columns, color = notable ? hot : color.new(cool, 40))
hline(1, "Average", color = color.new(cool, 50))
hline(threshold, "Threshold", color = color.new(hot, 50), linestyle = hline.style_dashed)
surged = notable and not notable[1]
alertcondition(surged, "Volume surge", "Relative volume crossed the notable threshold")
This runs in TradingView, not here
Pine Script only executes inside TradingView. Paste the source into the Pine Editor and add it to a chart to see it plotted.
What it will not do
- High relative volume marks interest, not direction. It appears on the way up and on the way down.
- Comparing intraday bars against a plain average ignores the time-of-day volume curve, so opens and closes read as unusual when they are normal.
Written from this description
Plot volume divided by its 20 period average as columns, draw a line at one and at a configurable threshold, and highlight the bars where the multiple crosses that threshold.
Educational only, not financial advice. The maths is simple arithmetic on the numbers you enter; it knows nothing about your broker, fees, slippage or the market. Something wrong with it? Say so in Site Feedback.