RicardoSantos

[RS]Multiple Bollinger Bands Candles V0

EXPERIMENTAL: using multiple length bollinger bands to create a better reading of ?price/range? strength?.
• calculates 2 candle plots for upper and lower bands, were the high and low are the extremes of the bands,
open is the previous close of the band and close is the extreme midline.
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?
study(shorttitle="[RS]mBBC V0", title="[RS]Multiple Bollinger Bands Candles V0", overlay=true)
length0 = input(4, minval=1)
length1 = input(8, minval=1)
length2 = input(16, minval=1)
length3 = input(32, minval=1)

src = input(close, title="Source")
mult = input(2.0, minval=0.001, maxval=50)

deviation(_s, _l) => mult * stdev(_s, _l)
base0 = sma(src, length0)
base1 = sma(src, length1)
base2 = sma(src, length2)
base3 = sma(src, length3)

upper0 = base0 + deviation(src, length0)
upper1 = base1 + deviation(src, length1)
upper2 = base2 + deviation(src, length2)
upper3 = base3 + deviation(src, length3)

lower0 = base0 - deviation(src, length0)
lower1 = base1 - deviation(src, length1)
lower2 = base2 - deviation(src, length2)
lower3 = base3 - deviation(src, length3)

mbb_upper_high = max(upper0, max(upper1, max(upper2, upper3)))
mbb_upper_low = min(upper0, min(upper1, min(upper2, upper3)))
mbb_upper_close = max(base0, max(base1, max(base2, base3)))
mbb_lower_high = max(lower0, max(lower1, max(lower2, lower3)))
mbb_lower_low = min(lower0, min(lower1, min(lower2, lower3)))
mbb_lower_close = min(base0, min(base1, min(base2, base3)))

upper_palete = falling(mbb_upper_close, 1)?orange:rising(mbb_upper_close, 1)?olive:silver
lower_palete = falling(mbb_lower_close, 1)?orange:rising(mbb_lower_close, 1)?olive:silver

plotbar(mbb_upper_close[1], mbb_upper_high, mbb_upper_low, mbb_upper_close, color=upper_palete)//, wickcolor=orange)
plotbar(mbb_lower_close[1], mbb_lower_high, mbb_lower_low, mbb_lower_close, color=lower_palete)//, wickcolor=olive)