Hi All,
Hope you are well. I am trying to replicate the attached Bollinger bandwidth indicator seen from tradingview and scripted as below:
A similar indicator on PRT only has the bandwidth oscillator without the marker lines for the lowest or highest of the previous lookback periods. Therefore i have been manually applying the horizontal lines for each market that i am looking at, which is a bit of work.
I appreciate anyone who can help with the code for this indicator. Let me know if you need more informaion.
Thank you,
Yomi
=======================================
//@version=4
study(title = “Bollinger Bandwidth – Bulge and squeeze”, shorttitle = “Bollinger Bandwidth”, format=format.price, precision=2, resolution=””)
length = input(20, minval=1)
src = input(close, title=”Source”)
mult = input(2.0, minval=0.001, maxval=50, title=”StdDev”)
highlowlength = input(20, minval=1, title=”High Low Lookback Short”)
[main, top, bottom] = bb(src, length, mult)
bandwidth = (top-bottom)/main
short_lowest = lowest(bandwidth, highlowlength)
short_highest = highest(bandwidth, highlowlength)
plot(bandwidth, “Bollinger Bandwidth”, color=color.blue)
p1 = plot(short_highest, color=color.green, title=”Lowest”)
p2 = plot(short_lowest, color=color.red, title=”Highest”)
fill(p1, p2, color = bandwidth> short_lowest? color.green : color.red, title=”Background”)
==========================================