Skip to content

Instantly share code, notes, and snippets.

@pequet
Last active June 25, 2018 23:59
Show Gist options
  • Save pequet/f0abde98a85e4130b93156e3cc3192be to your computer and use it in GitHub Desktop.
Save pequet/f0abde98a85e4130b93156e3cc3192be to your computer and use it in GitHub Desktop.
// Created by @pequet (https://www.tradingview.com/u/pequet) May 28 2018
// https://github.com/pequet/
// NOT FOR DISTRIBUTION
// @version=3
study(title="1' OBV v0.0.4", shorttitle="1' OBV", overlay=false)
// inputs
// ------
formulaInput = input("line", options=["line","candles"], title="Formula") // good idea or dumb idea?
// functions
// ---------
OnePeriod() => ismonthly ? 40320*interval
: isweekly ? 10080*interval
: isdaily ? 1440*interval
: interval
vol = cum(formulaInput=="line" ? ( change(close)>0 ? volume : change(close)<0 ? -volume : 0 ) : ( open<close ? volume : open>close ? -volume : 0 ))
obv = security(tickerid, '1', vol)
plot(obv, color=blue, transp=0, title="SOBV")
// -
@greg-oire
Copy link

bodysize = abs(open-close)
adjvol = volume*bodysize
volu = adjust ? adjvol : volume

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment