Double CCI
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © josappe

//@version=5
indicator(title='Double CCI', shorttitle='Double CCI', format=format.price, precision=0, timeframe='')
src = input(close, title='Source')
length_1 = input.int(10, title='Fast', minval=1)
length_2 = input.int(20, title='Slow', minval=2)
Null = input(true, title='Show Zero Line')
ma_1 = ta.sma(src, length_1)
ma_2 = ta.sma(src, length_2)

color cbuy = color.rgb(0, 255, 0, 60)
color csell = color.rgb(255, 0, 0, 60)

cci_1 = (src - ma_1) / (0.015 * ta.dev(src, length_1))
cci_2 = (src - ma_2) / (0.015 * ta.dev(src, length_2))

plot(cci_1, 'CCI Fast', color=color.rgb(255, 255, 0, 0), linewidth=1)
plot(cci_2, 'CCI Slow', color=color.rgb(255, 255, 255, 0), linewidth=2)

band0 = hline(Null ? 0 : na, color=color.rgb(200, 200, 200, 0), linestyle=hline.style_solid, linewidth=1, editable=0)

band1 = hline(100, 'Upper Band', color=cbuy, linestyle=hline.style_solid, editable=0)
band2 = hline(250, 'Top Band', color=cbuy, linestyle=hline.style_solid, editable=0)
band3 = hline(-100, 'Lower Band', color=csell, linestyle=hline.style_solid, editable=0)
band4 = hline(-250, 'Bottom Band', color=csell, linestyle=hline.style_solid, editable=0)

fill(band2, band1, color=cbuy, title='Background Buyers', editable=0, transp=90)
fill(band4, band3, color=csell, title='Background Sellers', editable=0, transp=90)

