traileriana

Price/OBV divergence

Shows agreement or disagreement between the direction of the the price and the on-balance volume. When they disagree, the price is supposed to follow the OBV (or so they say.)
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
//@version=2
study("Price/OBV divergence", "Price/OBV")
period = input(30, "Period")

// tanh(v) => (exp(v) - exp(-v))/(exp(v) + exp(-v))
// dema(x, p) => 2*ema(x, p) - ema(ema(x, p), p)

obv = cum(change(close) > 0 ? volume : change(close) < 0 ? -volume : 0*volume)

c = sign(change(ema(close, period)))
o = sign(change(ema(obv  , period)))

cc = c == o ? c : c/3*2
oo = o == c ? o : o/3*2

plot(cc, style=columns, transp = 50, color = red )
plot(oo, style=columns, transp = 50, color = blue)