Skip to content
GetProfitable
Search
Volume

Up and Down Volume Split

Volume separated into the bars that closed up and the bars that closed down and drawn either side of zero, with a smoothed net line so one-sided participation is visible instead of inferred.

indicator
//@version=6
indicator("Up and Down Volume Split", "UpDownVol")

basis = input.string("Previous close", "An up bar closes above", options = ["Previous close", "Bar open"], group = "Settings")
netLen = input.int(20, "Net average length", minval = 1, group = "Settings")
bull = input.color(#26A69A, "Up volume", group = "Style")
bear = input.color(#EF5350, "Down volume", group = "Style")
netCol = input.color(#787B86, "Net average", group = "Style")

reference = basis == "Bar open" ? open : nz(close[1], open)
upVol = close > reference ? volume : 0
downVol = close < reference ? volume : 0
net = upVol - downVol
netAvg = ta.sma(net, netLen)

plot(upVol, "Up volume", style = plot.style_columns, color = color.new(bull, 20))
plot(-downVol, "Down volume", style = plot.style_columns, color = color.new(bear, 20))
plot(netAvg, "Net average", color = netCol, linewidth = 2)
hline(0, "Zero", color = color.new(netCol, 50))

turnedUp = ta.crossover(netAvg, 0)
turnedDown = ta.crossunder(netAvg, 0)
plotshape(turnedUp, "Net turned positive", location = location.bottom, style = shape.triangleup, color = bull, size = size.tiny)
plotshape(turnedDown, "Net turned negative", location = location.top, style = shape.triangledown, color = bear, size = size.tiny)
alertcondition(turnedUp, "Net volume positive", "Average net volume crossed above zero")
alertcondition(turnedDown, "Net volume negative", "Average net volume crossed below zero")
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

  • This assigns a bar's entire volume by its close. It is not real up-tick and down-tick volume, which TradingView does not expose to Pine on a normal chart.
  • A doji or an unchanged close counts as neither side, so on very quiet symbols some volume simply disappears from both histograms.
  • The net average is a smoothing of a crude input. It lags, and it says nothing about the size of the price move that the volume produced.
  • TradingView reports tick count rather than traded size for spot forex, so the split counts ticks on each side, not money.

Written from this description

Split volume into up-closing and down-closing bars, draw it as a two-sided histogram around zero, add a moving average of the net difference, and alert when that net crosses zero.

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.