Skip to content

Instantly share code, notes, and snippets.

@robinraszka
Created October 26, 2018 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinraszka/aa6e1d4405c88edb91a0d81466289c1a to your computer and use it in GitHub Desktop.
Save robinraszka/aa6e1d4405c88edb91a0d81466289c1a to your computer and use it in GitHub Desktop.
//@version=3
study("OBV @robinraszka", "vOBV", precision=0)
len = input(26, "Period")
t = tickerid(syminfo.prefix, ticker, session.regular)
src = security(t, period, close)
obv(src) => cum(change(src) > 0 ? volume : change(src) < 0 ? - volume : 0 * volume)
osc = obv(src)
data = (osc - sma(osc, len))
hline(50, "Zero", silver)
plot(data, "OBV", black, 2, transp=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment