XYZ Super Fibonacci Channel Cluster
// This Suurce code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © akaes62
// XYZ Super Fibo Channel Expert V.1.0
//@version=5
indicator("XYZ Super Fibo Channel [satobe]", "XYZ Super Fibo", overlay=true)

//______________________________input set up____________________________________//
src = input.source(hlc3, "Source")
mult_u = input.float(2.618, "Upper Multiplier"
 , options=[0.236, 0.38, 0.5, 0.618, 0.78, 1, 1.618, 2.618, 3.618, 4.23]
 , tooltip = "Progressive Structure")
mult_i = input.float(1.618, "Lower Multiplier"
 , options=[0.236, 0.38, 0.5, 0.618, 0.78, 1, 1.618, 2.618, 3.618, 4.23]
 , tooltip = "Regressive Structure")
X_switch = input.bool(false
 , "Enable X Channel"
 , inline = "X Channel"
 , tooltip = "X length")
X_leng = input(13
 , "/"
 , inline = "X Channel")
Y_switch = input.bool(false
 , "Enable Y Channel"
 , inline = "Y Channel"
 , tooltip = "Y length")
Y_leng = input(21
 , "/"
 , inline = "Y Channel")
Z_switch = input.bool(false
 , "Enable Z Channel"
 , tooltip = "Z length = X length + Y Length [auto]")
Z_leng = X_leng + Y_leng
MA_switch = input.bool(true
 , "Enable EMA [XYZ]")
S_switch = input.bool(true
 , "Enable Super Channel"
 , tooltip = "Super length = Z length + Y length [auto]")
S_leng = Z_leng + Y_leng
Ch_leng = input(1600
 , "Channel Length") 

//__________________________________XYZ factor____________________________________//
//________________________________Super Channel___________________________________//
fX_u = (mult_u*4.238)
fY_u = (mult_u*2.618)
fZ_u = (mult_u*1.618)
fX_i = (mult_i*4.238)
fY_i = (mult_i*2.618)
fZ_i = (mult_i*1.618)

Super_fibo_ch(src, X_leng, Y_leng, Z_leng, S_leng, mult_u, mult_i) =>
    float X_bas = ta.ema(src, X_leng)
    float X_rma = ta.ema(high-low, X_leng)
    float Y_bas = ta.ema(src, Y_leng)
    float Y_rma = ta.ema(high-low, Y_leng)
    float Z_bas = ta.ema(src, Z_leng)
    float Z_rma = ta.ema(high-low, Z_leng)
    float S_bas = ta.ema(src, S_leng)
    float S_rma = ta.ema(high-low, S_leng)

    float X_u = X_bas + X_rma * mult_u
    float Y_u = Y_bas + Y_rma * mult_u
    float Z_u = Z_bas + Z_rma * mult_u
    float X_i = X_bas - X_rma * mult_i
    float Y_i = Y_bas - Y_rma * mult_i
    float Z_i = Z_bas - Z_rma * mult_i
    float SX_u = S_bas + S_rma * fX_u
    float SY_u = S_bas + S_rma * fY_u
    float SZ_u = S_bas + S_rma * fZ_u
    float S_u = S_bas + S_rma * mult_u
    float S_i = S_bas - S_rma * mult_i
    float SZ_i = S_bas - S_rma * fZ_i
    float SY_i = S_bas - S_rma * fY_i
    float SX_i = S_bas - S_rma * fX_i
    [X_u, Y_u, Z_u, SX_u, SY_u, SZ_u, S_u, X_bas, Y_bas, Z_bas, S_bas, S_i, SZ_i, SY_i, SX_i, Z_i, Y_i, X_i]
    
[X_u, Y_u, Z_u, SX_u, SY_u, SZ_u, S_u, X_bas, Y_bas, Z_bas, S_bas, S_i, SZ_i, SY_i, SX_i, Z_i, Y_i, X_i] = Super_fibo_ch( src, X_leng, Y_leng, Z_leng, S_leng, mult_u, mult_i)

//_______________________________Coloring______________________________________//
//------------------------overbought vs oversold-------------------------------//
col_super = X_bas > Y_bas and X_bas < S_bas ? color.new(color.lime,0) : X_bas > Y_bas and X_bas > S_bas ? color.new(color.yellow,0) : X_bas[1] < Y_bas and X_bas < S_bas ? color.new(color.maroon,0) : color.new(color.orange,0)
col_SX_u = X_bas > S_u ? color.new(color.yellow,23) : color.new(color.white,23)
col_SX_i = X_bas > S_i ? color.new(color.yellow,23) : color.new(color.white,23)

//___________________________Upper Lower________________________________________//
plot(X_switch ? X_u : na
 , "Upper X [X-u]" 
 , color.new(color.yellow,38)
 , show_last = Ch_leng)
plot(X_switch ? X_i : na
 , "Lower X [X-i]"
 , color.new(color.yellow,38)
 , show_last = Ch_leng)

plot(Y_switch ? Y_u : na
 , "Upper Y [Y-u]"
 , color.new(color.silver,38)
 , show_last = Ch_leng)
plot(Y_switch ? Y_i : na
 , "Lower Y [Y-i]"
 , color.new(color.silver,38)
 , show_last = Ch_leng)

plot(Z_switch ? Z_u : na
 , "Upper Z [Z-u]"
 , color.new(color.fuchsia,38)
 , show_last = Ch_leng)
plot(Z_switch ? Z_i : na
 , "Lower Z [Z-i]"
 , color.new(color.fuchsia,38)
 , show_last = Ch_leng)

plot(MA_switch ? X_bas : na
 , "Ema X"
 , color.new(color.yellow,23))
plot(MA_switch ? Y_bas : na
 , "Ema Y"
 , color.new(color.silver,23))
plot(MA_switch ? Z_bas : na
 , "Ema Z"
 , color.new(color.fuchsia,23))

//_____________________________Super plots____________________________________//
plot(S_switch ? SX_u : na
 , " Upper Super X [SX-u]"
 , color.new(color.red,44)
 , show_last = Ch_leng)
plot(S_switch ? SY_u : na
 , "Upper Super Y [SY-u]"
 , color.new(color.green,44)
 , show_last = Ch_leng)
plot(S_switch ? SZ_u : na
 , "Upper Super Z [SZ-u]"
 , color.new(color.blue,44)
 , show_last = Ch_leng)
plot(S_switch ? S_u : na
 , "Upper Super [S-u]"
 , color = col_SX_u
 , linewidth = 2
 , show_last = Ch_leng)
plot(S_switch ? S_bas : na
 , "EMA Super [Basic]"
 , color = col_super
 , linewidth = 2)
plot(S_switch ? S_i : na
 , "Lower Super [S-i]"
 , color = col_SX_i
 , linewidth = 2
 , show_last = Ch_leng)
plot(S_switch ? SZ_i : na
 , "Lower Super Z [SZ-i]"
 , color.new(color.blue,44)
 , show_last = Ch_leng)
plot(S_switch ? SY_i : na
 , "Lower Super Y [SY-i]"
 , color.new(color.green,44)
 , show_last = Ch_leng)
plot(S_switch ? SX_i : na
 , "Lower Super X [SX-i]"
 , color.new(color.red,44)
 , show_last = Ch_leng)


//_________________________________[satobe]__________________________________//