indicator · own pane · open source
On-Balance Volume
Running…
Loading chart…
About
On-Balance Volume (OBV) is the running total of volume signed by the bar's direction — a cumulative tape that leads price on breakouts.
- Rising OBV + flat price = accumulation; falling OBV + flat price = distribution.
- Divergences between OBV and price are the classic smart-money signal.
Source code
//@version=5
indicator("On-Balance Volume", overlay=false)
src = input.source("close", "Source")
chg = src - src[1]
dir = chg > 0 ? 1 : chg < 0 ? -1 : 0
obv = ta.cum(dir * volume)
p_OBV = plot(obv, "OBV", color=color.blue, linewidth=2)
alertcondition(ta.crossover(obv, ta.highest(obv, 50)), "New 50-bar OBV high", "OBV printed a new 50-bar high")
alertcondition(ta.crossunder(obv, ta.lowest(obv, 50)), "New 50-bar OBV low", "OBV printed a new 50-bar low")
No comments yet.
Sign in to comment.