Skip to content

Instantly share code, notes, and snippets.

@alexcrownjr
Created April 30, 2019 06:06
Show Gist options
  • Save alexcrownjr/9595a0d07230ef633ad89356f77432ea to your computer and use it in GitHub Desktop.
Save alexcrownjr/9595a0d07230ef633ad89356f77432ea to your computer and use it in GitHub Desktop.
study(title="Bollinger Bands Width", shorttitle="BBW")
length = input(20, minval=1)
src = input(close, title="Source")
mult = input(2.0, minval=0.001, maxval=50)
percentage = input(10.0, minval=0.5, maxval=50)
basis = sma(src, length)
dev = mult * stdev(src, length)
upper = basis + dev
lower = basis - dev
bbw = (100 * (upper/lower -1))
band1 = hline(percentage, color=gray, linestyle=dashed)
band0 = hline(0, color=gray, linestyle=dashed)
fill(band1, band0, color=teal)
plot(bbw, color=blue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment