Skip to content

volume - PineScript Variable

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.

  • 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.
  • volume reflects post-adjustment data when the chart uses modifiers (split-adjusted equities, etc.).
//@version=5
indicator("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")