volume - PineScript Variable
volume
Section titled “volume”Overview
Section titled “Overview”volume counts how many units (contracts, shares, lots, etc.) have traded during the current bar. The value grows as trades occur and becomes final when the bar closes.
Remarks
Section titled “Remarks”- Access historical activity with
volume[1],volume[2], etc., to build volume-based indicators. - On some symbols (e.g., Forex, crypto indices) the series may represent tick volume rather than actual exchange volume.
volumereflects post-adjustment data when the chart uses modifiers (split-adjusted equities, etc.).
Example
Section titled “Example”//@version=5indicator("Volume surge detector", overlay=false)
lookback = input.int(20, "Average length", minval=1)avgVolume = ta.sma(volume, lookback)
plot(volume, "Volume", style=plot.style_columns, color=color.new(color.blue, 0))plot(avgVolume, "Average", color=color.orange, linewidth=2)
bgcolor(volume > avgVolume * 1.5 ? color.new(color.green, 85) : na, title="High-volume bar")