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.)
//@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)