Bands Bands (BanB)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © More-Than-Enough

//@version=5
indicator("Bands Bands", "BanB", true)

Spikes_On = input.bool(false, "Spike Bands")
Arls_On = input.bool(true, "ARL Bands")
Plunges_On = input.bool(false, "Plunge Bands")

Middle = 0.0
A = 0.5
B = 1.2
C = 1.8
D = 2.3
E = 3.15
F = 4.0
G = 5.0
H = 8.0
I = 11.0

/// ARL Bands ///
Length = 14
Exponent = 0
Source = hlc3
Secondary_Source = low
ARL = (ta.ema(Secondary_Source, Length)[1] + (Source - ta.ema(Secondary_Source, Length)[1]) / (Length * math.pow(Source / ta.ema(close, Length)[1], Exponent)))

Arl_Peak = ARL * (1.00 + (F * 0.01))
Arl_Top  = ARL * (1.00 + (E * 0.01))
Arl_High = ARL * (1.00 + (D * 0.01))

Arl_Mid_Peak = ARL * (1.00 + (C * 0.01))
Arl_Mid_Top  = ARL * (1.00 + (B * 0.01))
Arl_Mid_High = ARL * (1.00 + (A * 0.01))

Arl_Middle = ARL * (1.00 + (Middle * 0.01))

Arl_Mid_Low    = ARL * (1.00 + (-A * 0.01))
Arl_Mid_Bottom = ARL * (1.00 + (-B * 0.01))
Arl_Mid_Dip    = ARL * (1.00 + (-C * 0.01))

Arl_Low    = ARL * (1.00 + (-D * 0.01))
Arl_Bottom = ARL * (1.00 + (-E * 0.01))
Arl_Dip    = ARL * (1.00 + (-F * 0.01))

/// Spike Bands ///
Top_Spike_Line    = ta.sma(low - (ta.atr(20) * -I), 75)
Middle_Spike_Line = ta.sma(low - (ta.atr(20) * -H), 75)
Bottom_Spike_Line = ta.sma(low - (ta.atr(20) * -G), 75)

/// Plunge Bands ///
Top_Plunge_Line    = ta.sma(low - (ta.atr(20) * G), 75)
Middle_Plunge_Line = ta.sma(low - (ta.atr(20) * H), 75)
Bottom_Plunge_Line = ta.sma(low - (ta.atr(20) * I), 75)

/// Plots ///
plot(Spikes_On ? Top_Spike_Line : na, "Spike Top Line", color.rgb(34, 171, 148), linewidth = 3)
plot(Spikes_On ? Middle_Spike_Line: na, "Spike Middle Line", color.rgb(102, 187, 106), linewidth = 3)
plot(Spikes_On ? Bottom_Spike_Line: na, "Spike Bottom Line", color.rgb(165, 214, 167), linewidth = 3)

plot(Plunges_On ? Top_Plunge_Line : na, "Plunge Top Line", color.rgb(250, 161, 164), linewidth = 3)
plot(Plunges_On ? Middle_Plunge_Line : na, "Plunge Middle Line", color.rgb(247, 82, 95), linewidth = 3)
plot(Plunges_On ? Bottom_Plunge_Line : na, "Plunge Bottom Line", color.rgb(178, 40, 51), linewidth = 3)

Peak_Line = plot(Arls_On ? Arl_Peak : na, "Peak", color.rgb(178, 235, 242), linewidth = 2)
Top_Line  = plot(Arls_On ? Arl_Top : na, "Top", color.rgb(77, 208, 225), linewidth = 2)
High_Line = plot(Arls_On ? Arl_High : na, "High", color.rgb(0, 151, 167), linewidth = 2)

Mid_Peak_Line = plot(Arls_On ? Arl_Mid_Peak : na, "Middle Peak", color.rgb(0, 151, 167))
Mid_Top_Line  = plot(Arls_On ? Arl_Mid_Top : na, "Middle Top", color.gray)
Mid_High_Line = plot(Arls_On ? Arl_Mid_High : na, "Middle High", color.gray)

Middle_Line = plot(Arls_On ? Arl_Middle : na, "Middle", color.white, display = display.none)

Mid_Low_Line    = plot(Arls_On ? Arl_Mid_Low : na, "Middle Low", color.gray)
Mid_Bottom_Line = plot(Arls_On ? Arl_Mid_Bottom : na, "Middle Bottom", color.gray)
Mid_Dip_Line    = plot(Arls_On ? Arl_Mid_Dip : na, "Middle Dip", color.rgb(0, 151, 167))

Low_Line    = plot(Arls_On ? Arl_Low : na, "Low", color.rgb(0, 151, 167), linewidth = 2)
Bottom_Line = plot(Arls_On ? Arl_Bottom : na, "Bottom", color.rgb(77, 208, 225), linewidth = 2)
Dip_Line    = plot(Arls_On ? Arl_Dip : na, "Dip", color.rgb(178, 235, 242), linewidth = 2)

fill(Top_Line, Peak_Line, color.rgb(0, 151, 167, 85), "Peak Zone")
fill(High_Line, Top_Line, color.rgb(77, 208, 225, 85), "Top Zone")
fill(Mid_High_Line, High_Line, color.rgb(178, 235, 242, 85), "High Zone")

fill(Mid_Low_Line, Mid_High_Line, color.rgb(91, 156, 246, 85), "Middle Zone")

fill(Mid_Low_Line, Low_Line, color.rgb(178, 235, 242, 85), "Low Zone")
fill(Low_Line, Bottom_Line, color.rgb(77, 208, 225, 85), "Bottom Zone")
fill(Bottom_Line, Dip_Line, color.rgb(0, 151, 167, 85), "Dip Zone")

/// Alerts ///
Opportunity = ta.crossunder(low, Arl_Mid_Dip) or ta.crossover(high, Arl_Mid_Peak)
alertcondition(Opportunity, "Opportunity Zone", "Opportunity reached!")