Docs

ITMScript

Draw Bollinger bands with a filled channel

Draw Bollinger bands around a moving average and fill the space between the upper and lower band.

Draw a channel around an average at a set number of standard deviations and fill it.

itm
//@itmscript 2
study("Bollinger channel", overlay=true)
len = input.int(20, "Length", min=2, max=300)
mult = input.float(2, "Deviations", min=0.5, max=5, step=0.1)
src = input.source(close, "Source")
tint = input.color(color.blue, "Channel")
[basis, upper, lower] = ta.bb(src, len, mult)
up = plot(upper, "Upper", color=tint, width=1, style=line)
lo = plot(lower, "Lower", color=tint, width=1, style=line)
plot(basis, "Basis", color=color.gray, width=1, style=line)
fill(up, lo, color=color.new(color.blue, 92))

What you see

Two band lines are drawn over the candles in the colour you choose. A grey line shows the average between them. The space between the bands is lightly filled.

The bands widen when prices move more and narrow when they move less. The channel starts once the window has filled.

Change these inputs

  • Length. The window of the average and of the deviation, from 2 to 300 bars.
  • Deviations. How far each band sits from the average, in standard deviations. From 0.5 to 5. A larger number puts the bands further out.
  • Source. The series the bands are built on. It is the close until you change it.
  • Channel. The colour of the two band lines. The fill keeps the colour written in the script. Edit color.blue in the fill line to change it.