Riles' Rotation
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Boppsy

//@version=5
indicator(title="Riles' Rotation", shorttitle="BTC 1H", overlay=true, timeframe="", timeframe_gaps=true)
length = input.int(250, minval=1)
mult_upper1 = input(2.5, "Upper Multiplier 1")
mult_upper2 = input(4, "Upper Multiplier 2")
mult_upper3 = input(6, "Upper Multiplier 3")
mult_upper4 = input(8.5, "Upper Multiplier 4")
mult_upper5 = input(10, "Upper Multiplier 5")
mult_upper6 = input(16, "Upper Multiplier 6")
mult_lower1 = input(2.5, "Lower Multiplie 1")
mult_lower2 = input(4, "Lower Multiplier 2")
mult_lower3 = input(6, "Lower Multiplier 3")
mult_lower4 = input(8.5, "Lower Multiplier 4")
mult_lower5 = input(10, "lower Multiplier 5")
mult_lower6 = input(23, "Lower Multiplier 6")
src = input(close, title="Source")
exp = input(true, "Use Exponential MA")
BandsStyle = input.string("Range", options = ["Average True Range", "True Range", "Range"], title="Bands Style")
atrlength = input(10, "ATR Length")
esma(source, length)=>
	s = ta.sma(source, length)
	e = ta.ema(source, length)
	exp ? e : s
ma = esma(src, length)
rangema = BandsStyle == "True Range" ? ta.tr(true) : BandsStyle == "Average True Range" ? ta.atr(atrlength) : ta.rma(high - low, length)
upper1 = ma + rangema * mult_upper1
upper2 = ma + rangema * mult_upper2
upper3 = ma + rangema * mult_upper3
upper4 = ma + rangema * mult_upper4
upper5 = ma + rangema * mult_upper5
upper6 = ma + rangema * mult_upper6

lower1 = ma - rangema * mult_lower1
lower2 = ma - rangema * mult_lower2
lower3 = ma - rangema * mult_lower3
lower4 = ma - rangema * mult_lower4
lower5 = ma - rangema * mult_lower5
lower6 = ma - rangema * mult_lower6

u1 = plot(upper1, color=#000000, title="Upper1")
u2 = plot(upper2, color=#000000, title="Upper2")
u3 = plot(upper3, color=#000000, title="Upper3")
u4 = plot(upper4, color=#000000, title="Upper4")
u5 = plot(upper5, color=#000000, title="Upper5")
u6 = plot(upper6, color=#000000, title="Upper6")
plot(ma, color=#7B1818, title="Basis")
l1 = plot(lower1, color=#000000, title="Lower1")
l2 = plot(lower2, color=#000000, title="Lower2")
l3 = plot(lower3, color=#000000, title="Lower3")
l4 = plot(lower4, color=#000000, title="Lower4")
l5 = plot(lower5, color=#000000, title="Lower5")
l6 = plot(lower6, color=#000000, title="Lower6")
fill(u1, l1, color=color.rgb(123, 24, 24, 95), title="Background")
fill(u4, u5, color=color.rgb (0, 0, 100, 95), title="Upper background")
fill(l4, l5, color=color.rgb (0, 0, 100, 95), title= "lower background")

