Custom OBV Oscillator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jsalemfinancial

//@version=5
indicator(title="Custom OBV Oscillator", shorttitle="OBVO", precision=2)

lookback_len = input.int(defval=20, title="Lookback Period")
fast_len = input.int(defval=3, title="Fast Period")

obvo(src) => ta.cum(ta.change(src) > 0 ? volume : -volume)

os = obvo(close) - obvo(close)[lookback_len]
obv_osc = os + ta.ema(os, fast_len)

obv_color = if obv_osc > 0 
    #b1d930
else
    #d12e41

hline(0, color= color.gray)
plot(obv_osc, color= obv_color, style= plot.style_histogram, linewidth = 2, title="OBV")
plot(ta.sma(obv_osc, 10), color= color.red)
plot(ta.sma(obv_osc, 20), color= color.blue)