NomadandTrader

Bollinger Bands Color

Bollinger Bands Color
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
//Crée par J.Dow
//Boullinger Band color
study(shorttitle="BB color", title="Bollinger Bands color", overlay=true)

length = input(20, minval=1, title ="MA - Simpel")
len = input(2, minval=1, title="MA - Exponantial")
src = input(close, title="Source")
mult = input(2.0, minval=0.001, maxval=50)

//Bollinger Bands
basis = sma(src, length)
dev = mult * stdev(src, length)
upper = basis + dev
lower = basis - dev

price = ema(src, len)
linecolor = price >= basis ? green : red


//Affichage

plot(basis, color=red, transp=50)
p1 = plot(upper, color=linecolor, transp=90)
p2 = plot(lower, color=linecolor, transp=90)
fill(p1, p2, color=linecolor)