Support & Resistance Trendlines with PP + Fib. Channel
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5

indicator("S&R • Yata", 
     overlay = true,
     max_bars_back = 5000)

// ---------------------
groupPP = "Pivot Points"
groupPL = "Pivot Labels & Lines"
groupSR = "Support & Resistance"
groupFR = "Fibonacci Retracement"
groupFE = "Fibonacci Extension"
// ---------------------

length					= input			(21			, title="Length"				, inline="PP1", group=groupPP)
//max_h_pivot_points	= input.float	(5, minval=2, title="Lookback: High"		, inline="PP2", group=groupPP)
//max_l_pivot_points	= input.float	(5, minval=2, title="Low"					, inline="PP2", group=groupPP)
max_pivot_points		= input.float	(5, minval=2, title="Pivot Points Lookback"	, inline="PP2", group=groupPP)
max_h_pivot_points		= max_pivot_points
max_l_pivot_points		= max_pivot_points
//min_difference		= input.float	(0.0		, title=""						, inline="", group=groupPP)
min_difference			= 0.0
channel_ext_length		= input			(14			, title="Lines Extension"		, inline="EXT", group=groupPP)
source					= input			(close		, title="Source"				, inline="PP1", group=groupPP)

// ---------------------

show_plabels = input.bool(true, title="Show Pivot Labels", inline="PP4", group=groupPL)

//d_lbl_pivh = input.bool(true, title="Draw Pivot High Labels", inline="", group=groupPL)
//d_lbl_pivl = input.bool(true, title="Draw Pivot Low Labels", inline="", group=groupPL)

d_lbl_pivh = show_plabels ? true : false
d_lbl_pivl = show_plabels ? true : false

ALB1 = input.color(color.new(#99D31B, 25), title="Active"	, inline="PP4A", group=groupPL) // Active Pivot High Labels
ALB2 = input.color(color.new(#FA5032, 25), title=""			, inline="PP4A", group=groupPL) // Active Pivot Low Labels
ILB1 = input.color(color.new(#99D31B, 75), title="| Inactive",inline="PP4A", group=groupPL) // Inactive Pivot High Labels
ILB2 = input.color(color.new(#FF4500, 75), title=""			, inline="PP4A", group=groupPL) // Inactive Pivot Low Labels

// ---------------------

show_plines	= input.bool(true, title="Show Pivot Lines"		, inline="PP5", group=groupPL)

//d_pivh	= input.bool(true, title="Draw Pivot High Lines", inline="", group=groupPL)
//d_pivl	= input.bool(true, title="Draw Pivot Low Lines"	, inline="", group=groupPL)

d_pivh		= show_plines ? true : false
d_pivl		= show_plines ? true : false

ALN1 = input.color(color.new(#99D31B, 50), title="Active"	, inline="PP5A", group=groupPL) // Active Pivot High Lines
ALN2 = input.color(color.new(#FA5032, 50), title=""			, inline="PP5A", group=groupPL) // Active Pivot Low Lines
ILN1 = input.color(color.new(#99D31B, 50), title="Inactive"	, inline="PP5B", group=groupPL) // Inactive Pivot High Lines
ILN2 = input.color(color.new(#FF4500, 50), title=""			, inline="PP5B", group=groupPL) // Inactive Pivot Low Lines

// ---------------------

show_chan	= input.bool(true, title="Show Channel Lines"	, inline="CH1", group=groupSR)

//d_chanh	= input.bool(true, title="Draw Channel High"	, inline="", group=groupSR)
//d_chanl	= input.bool(true, title="Draw Channel Low"		, inline="", group=groupSR)

d_chanh		= show_chan ? true : false
d_chanl		= show_chan ? true : false

show_extendL = input.bool(false, title="Extend Channel Lines"		, inline="CH1B", group=groupSR)
extendL = show_extendL ? extend.left : extend.none

RLN	= input.color(color.new(#99D31B, 25), title="High"		, inline="CH1A", group=groupSR) // Resistance Line
SLN = input.color(color.new(#FA5032, 25), title="Low"		, inline="CH1A", group=groupSR) // Support Line

// ---------------------

d_fib = input.bool(true, title="Draw Fib. Retr. Lines", inline="CH2", group=groupFR)

FRH = input.color(color.new(#99D31B, 25), title="High"		, inline="CH2A", group=groupFR) // Fibonacci Retracement High
FRL = input.color(color.new(#FA5032, 25), title="Low"		, inline="CH2A", group=groupFR) // Fibonacci Retracement Low
	
sfib_R01 = input.bool(true				, title="01"		, inline="CH21", group=groupFR)
sfib_R02 = input.bool(true				, title="02"		, inline="CH22", group=groupFR)
sfib_R03 = input.bool(true				, title="03"		, inline="CH23", group=groupFR)
sfib_R04 = input.bool(true				, title="04"		, inline="CH24", group=groupFR)
sfib_R05 = input.bool(true				, title="05"		, inline="CH25", group=groupFR)

fib_R01 = sfib_R01 ? input.float(0.236	, title=""			, inline="CH21", group=groupFR) : na
fib_R02 = sfib_R02 ? input.float(0.382	, title=""			, inline="CH22", group=groupFR) : na
fib_R03 = sfib_R03 ? input.float(0.5	, title=""			, inline="CH23", group=groupFR) : na
fib_R04 = sfib_R04 ? input.float(0.618	, title=""			, inline="CH24", group=groupFR) : na
fib_R05 = sfib_R05 ? input.float(0.786	, title=""			, inline="CH25", group=groupFR) : na

sfib_R06 = input.bool(false				, title="06"		, inline="CH21", group=groupFR)
sfib_R07 = input.bool(false				, title="07"		, inline="CH22", group=groupFR)
sfib_R08 = input.bool(false				, title="08"		, inline="CH23", group=groupFR)
sfib_R09 = input.bool(false				, title="09"		, inline="CH24", group=groupFR)
sfib_R10 = input.bool(false				, title="10"		, inline="CH25", group=groupFR)

fib_R06 = sfib_R06 ? input.float(0.09	, title=""			, inline="CH21", group=groupFR) : na
fib_R07 = sfib_R07 ? input.float(0.146	, title=""			, inline="CH22", group=groupFR) : na
fib_R08 = sfib_R08 ? input.float(0.35	, title=""			, inline="CH23", group=groupFR) : na
fib_R09 = sfib_R09 ? input.float(0.65	, title=""			, inline="CH24", group=groupFR) : na
fib_R10 = sfib_R10 ? input.float(0.886	, title=""			, inline="CH25", group=groupFR) : na

// ---------------------

d_fib2 = input.bool(true, title="Draw Fib. Ext. Lines", inline="CH3", group=groupFE)

FEH = input.color(color.new(#99D31B, 25), title="High"		, inline="CH3A", group=groupFE) // Fibonacci Extension High
FEL = input.color(color.new(#FA5032, 25), title="Low"		, inline="CH3A", group=groupFE) // Fibonacci Extension Low

sfib_E01 = input.bool(true				, title="01"		, inline="CH31", group=groupFE)
sfib_E02 = input.bool(false				, title="02"		, inline="CH32", group=groupFE)
sfib_E03 = input.bool(true				, title="03"		, inline="CH33", group=groupFE)
sfib_E04 = input.bool(false				, title="04"		, inline="CH34", group=groupFE)

fib_E01 = sfib_E01 ? input.float(1.618	, title=""			, inline="CH31", group=groupFE) : na
fib_E02 = sfib_E02 ? input.float(2		, title=""			, inline="CH32", group=groupFE) : na
fib_E03 = sfib_E03 ? input.float(-0.618	, title=""			, inline="CH33", group=groupFE) : na
fib_E04 = sfib_E04 ? input.float(-1		, title=""			, inline="CH34", group=groupFE) : na

sfib_E05 = input.bool(false				, title="05"		, inline="CH31", group=groupFE)
sfib_E06 = input.bool(false				, title="06"		, inline="CH32", group=groupFE)
sfib_E07 = input.bool(false				, title="07"		, inline="CH33", group=groupFE)
sfib_E08 = input.bool(false				, title="08"		, inline="CH34", group=groupFE)

fib_E05 = sfib_E05 ? input.float(1.13	, title=""			, inline="CH31", group=groupFE) : na
fib_E06 = sfib_E06 ? input.float(1.272	, title=""			, inline="CH32", group=groupFE) : na
fib_E07 = sfib_E07 ? input.float(1.41	, title=""			, inline="CH33", group=groupFE) : na
fib_E08 = sfib_E08 ? input.float(1.786	, title=""			, inline="CH34", group=groupFE) : na

// ---------------------

f_bg = input.bool(true, title="Fill Channel Background"		, inline="CH4", group=groupSR)

GF2 = input.color(color.new(#99D31B, 0)	, title="Rising"	, inline="CH4A", group=groupSR) // Falling Fill
GF1 = input.color(color.new(#FF4500, 0)	, title="Falling"	, inline="CH4A", group=groupSR) // Rising Fill

f_transp = input.float(97				, title="| Tra."	, inline="CH4A", group=groupSR)

// ---------------------

lwidth_piv	= input.int(1, minval=0, title="| Width", inline="PP5", group=groupPL)
lwidth_chan	= input.int(2, minval=0, title="| Width", inline="CH1", group=groupSR)
lwidth_FR	= input.int(1, minval=0, title="| Width", inline="CH2", group=groupFR)
lwidth_FE	= input.int(1, minval=0, title="| Width", inline="CH3", group=groupFE)

i_line0 = "Solid"
i_line1 = "Dotted"
i_line2 = "Dashed"

ppstyleAHL_input = input.string(i_line2, title="|", options=[i_line0, i_line1, i_line2], inline="PP5A", group=groupPL) // Active Pivot Lines
ppstyleIHL_input = input.string(i_line1, title="|", options=[i_line0, i_line1, i_line2], inline="PP5B", group=groupPL) // Inactive Pivot Lines
ppstyleSRL_input = input.string(i_line0, title="|", options=[i_line0, i_line1, i_line2], inline="CH1A", group=groupSR) // Support and Resistance Lines
ppstyleFRL_input = input.string(i_line1, title="|", options=[i_line0, i_line1, i_line2], inline="CH2A", group=groupFR) // Fibonacci Retracement Lines
ppstyleFEL_input = input.string(i_line1, title="|", options=[i_line0, i_line1, i_line2], inline="CH3A", group=groupFE) // Fibonacci Extension Lines

f_getLineStyle(_inputStyle) =>
    _return = _inputStyle == i_line1 ? line.style_dotted : _inputStyle == i_line2 ? line.style_dashed : line.style_solid
    _return

// ---------------------

var ph_index = array.new_int()
var pl_index = array.new_int()
var ph_value = array.new_float()
var pl_value = array.new_float()

interp(l, h, s) => l + (h - l) * s

// ---------------------

ph = ta.pivothigh(source, length, length)
if ph
    ok = true
    
    ph := high[length]
    
    if array.size(ph_index) > 0
        if array.size(ph_index) >= max_h_pivot_points
            array.shift(ph_index)
            array.shift(ph_value)

        for i = 0 to array.size(ph_value) - 1
            if math.abs(ph - array.get(ph_value, i)) < min_difference
                ok := false
                if ph > array.get(ph_value, i)
                    array.set(ph_value, i , ph)
                    array.set(ph_index, i , bar_index[length])
    
    if ok
        array.push(ph_index, bar_index[length])
        array.push(ph_value, ph)

// ---------------------

pl = ta.pivotlow(source, length, length)  
if pl
    ok = true
    
    pl := low[length]
    
    if array.size(pl_index) > 0
        if array.size(pl_index) >= max_l_pivot_points
            array.shift(pl_index)
            array.shift(pl_value)
    
        for i = 0 to array.size(pl_value) - 1
            if math.abs(pl - array.get(pl_value, i)) < min_difference
                ok := false
                if pl < array.get(pl_value, i)
                    array.set(pl_value, i , pl)
                    array.set(pl_index, i , bar_index[length])
    if ok
        array.push(pl_index, bar_index[length])
        array.push(pl_value, pl)

// ---------------------

var lines  = array.new_line()
var labels = array.new_label()
var fibs   = array.new_line()

var line line_fc_up   = line(na)
var line line_fc_down = line(na)
var linefill fill_fc  = linefill(na)

// ---------------------

if barstate.isconfirmed
    ph_count = array.size(ph_index)
    pl_count = array.size(pl_index)
    
    for i = 0 to array.size(lines)
        if array.size(lines) > 0
            line.delete(array.shift(lines))
            
    for i = 0 to array.size(labels)
        if array.size(labels) > 0
            label.delete(array.shift(labels))

    if ph_count > 0
        for i = 0 to ph_count - 1
//            alpha = 80//math.min(100 - int((i / (ph_count - 1)) * 100), 80)
//            clr   = color.from_gradient(100 - alpha, 0, 100, #E8E965, #99D31B)
            if d_lbl_pivh
                array.push(labels, label.new(array.get(ph_index, i), array.get(ph_value, i), "", style=label.style_label_down, color=ILB1, size=size.tiny))
            if d_pivh
                array.push(lines, line.new(array.get(ph_index, i), array.get(ph_value, i), bar_index + channel_ext_length, array.get(ph_value, i), color=ILN1, width=lwidth_piv, style=f_getLineStyle(ppstyleIHL_input), extend=extend.none))
    if pl_count > 0
        for i = 0 to pl_count - 1
//            alpha = 80//math.min(100 - int((i / (pl_count - 1)) * 100), 80)
//            clr   = color.from_gradient(100 - alpha, 0, 100, #64C5C7, #FA5032)
            if d_lbl_pivl
                array.push(labels, label.new(array.get(pl_index, i), array.get(pl_value, i), "", style=label.style_label_up, color=ILB2, size=size.tiny))
            if  d_pivl
                array.push(lines, line.new(array.get(pl_index, i), array.get(pl_value, i), bar_index + channel_ext_length, array.get(pl_value, i), color=ILN2, width=lwidth_piv, style=f_getLineStyle(ppstyleIHL_input), extend=extend.none))

// ---------------------

    if d_chanh
        if ph_count > 1
            tmp_arr = array.new_line()
            for i = 0 to ph_count - 1
                for j = 0 to ph_count - 1
                    h0  = array.get(ph_value, i)
                    h1  = array.get(ph_value, j)
                    h0i = array.get(ph_index, i) //array.indexof(ph_value, h0))
                    h1i = array.get(ph_index, j) //array.indexof(ph_value, h1))
                    if h0i < h1i 
                        array.push(tmp_arr, line.new(h0i, h0, h1i, h1, color=RLN, width=lwidth_chan, extend=extend.none, style=f_getLineStyle(ppstyleSRL_input)))
                    if h0i > h1i 
                        array.push(tmp_arr, line.new(h1i, h1, h0i, h0, color=RLN, width=lwidth_chan, extend=extend.none, style=f_getLineStyle(ppstyleSRL_input)))
            
            int   min_ind = na
            float min_val = 100000.0
            for i = 0 to array.size(tmp_arr) - 1
                lp = line.get_price(array.get(tmp_arr, i), bar_index)
                if lp > high
                    if min_val > math.abs(lp - close)
                        min_val := math.abs(lp - close)
                        min_ind := i
                        
            if not na(min_ind)
                line.delete(line_fc_up[1])
                best_line = array.get(tmp_arr, min_ind)
                line_fc_up := line.new(line.get_x1(best_line), line.get_y1(best_line), line.get_x2(best_line), line.get_y2(best_line), color=RLN, width=lwidth_chan, extend=extendL, style=f_getLineStyle(ppstyleSRL_input))
                
            for i = 0 to array.size(tmp_arr) - 1
                if array.size(tmp_arr) > 0
                    line.delete(array.shift(tmp_arr))
                    
            for l in labels
                if label.get_x(l) == line.get_x1(line_fc_up) or label.get_x(l) == line.get_x2(line_fc_up)
                    label.set_color(l, ALB1)
                    
            for l in lines
                if line.get_x1(l) == line.get_x1(line_fc_up) or line.get_x1(l) == line.get_x2(line_fc_up)
                    line.set_color(l, ALN1)
                    line.set_style(l, f_getLineStyle(ppstyleAHL_input))
					line.set_width(l, lwidth_piv)
            
        line.set_y2(line_fc_up, line.get_price(line_fc_up, bar_index + channel_ext_length))     
        line.set_x2(line_fc_up, bar_index + channel_ext_length)

// ---------------------

    if d_chanl
        if pl_count > 1
            tmp_arr = array.new_line()
            for i = 0 to pl_count - 1
                for j = 0 to pl_count - 1
                    l0  = array.get(pl_value, i)
                    l1  = array.get(pl_value, j)
                    l0i = array.get(pl_index, i) //array.indexof(pl_value, l0))
                    l1i = array.get(pl_index, j) //array.indexof(pl_value, l1))
                    if l0i < l1i
                        array.push(tmp_arr, line.new(l0i, l0, l1i, l1, color=SLN, width=lwidth_chan, extend=extend.none, style=f_getLineStyle(ppstyleSRL_input)))
                    if l0i > l1i
                        array.push(tmp_arr, line.new(l1i, l1, l0i, l0, color=SLN, width=lwidth_chan, extend=extend.none, style=f_getLineStyle(ppstyleSRL_input)))

            int   min_ind = na
            float min_val = 100000.0
            for i = 0 to array.size(tmp_arr) - 1
                lp = line.get_price(array.get(tmp_arr, i), bar_index)
                if lp < low
                    if min_val > math.abs(lp - close)
                        min_val := math.abs(lp - close)
                        min_ind := i
                        
            if not na(min_ind)
                line.delete(line_fc_down[1])
                best_line = array.get(tmp_arr, min_ind)
                line_fc_down := line.new(line.get_x1(best_line), line.get_y1(best_line), line.get_x2(best_line), line.get_y2(best_line), color=SLN, width=lwidth_chan, extend=extendL, style=f_getLineStyle(ppstyleSRL_input))
                
            for i = 0 to array.size(tmp_arr) - 1
                if array.size(tmp_arr) > 0
                    line.delete(array.shift(tmp_arr))
                    
            for l in labels
                if label.get_x(l) == line.get_x1(line_fc_down) or label.get_x(l) == line.get_x2(line_fc_down)
                    label.set_color(l, ALB2)
            
            for l in lines
                if line.get_x1(l) == line.get_x1(line_fc_down) or line.get_x1(l) == line.get_x2(line_fc_down)
                    line.set_color(l, ALN2)
                    line.set_style(l, f_getLineStyle(ppstyleAHL_input))
					line.set_width(l, lwidth_piv)
    
            line.set_y2(line_fc_down, line.get_price(line_fc_down, bar_index + channel_ext_length))     
            line.set_x2(line_fc_down, bar_index + channel_ext_length)

// ---------------------

    if not na(line_fc_up) and not na(line_fc_down) and f_bg
        linefill.delete(fill_fc[1])
        fill_color = color.new(color.from_gradient(ta.rsi(close, 14), 30, 70, GF1, GF2), f_transp)
        fill_fc   := linefill.new(line_fc_up, line_fc_down, fill_color)
    
    if not na(line_fc_up) and not na(line_fc_down) and d_fib
        for i = 0 to array.size(fibs) - 1
            if array.size(fibs) > 0
                line.delete(array.shift(fibs))

        left  = math.min(line.get_x1(line_fc_up), line.get_x1(line_fc_down))
        right = bar_index + channel_ext_length
        left_val   = interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_R01)
        right_val  = interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_R01)
        array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFRL_input), width=lwidth_FR, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FRL, FRH)))
        left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_R02)
        right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_R02)
        array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFRL_input), width=lwidth_FR, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FRL, FRH)))
        left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_R03)
        right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_R03)
        array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFRL_input), width=lwidth_FR, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FRL, FRH)))
        left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_R04)
        right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_R04)
        array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFRL_input), width=lwidth_FR, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FRL, FRH)))
        left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_R05)
        right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_R05)
        array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFRL_input), width=lwidth_FR, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FRL, FRH)))

        left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_R06)
        right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_R06)
        array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFRL_input), width=lwidth_FR, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FRL, FRH)))
        left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_R07)
        right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_R07)
        array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFRL_input), width=lwidth_FR, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FRL, FRH)))
        left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_R08)
        right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_R08)
        array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFRL_input), width=lwidth_FR, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FRL, FRH)))
        left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_R09)
        right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_R09)
        array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFRL_input), width=lwidth_FR, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FRL, FRH)))
        left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_R10)
        right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_R10)
        array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFRL_input), width=lwidth_FR, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FRL, FRH)))

        if d_fib2
            left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_E01)
            right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_E01)
            array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFEL_input), width=lwidth_FE, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FEL, FEH)))
            left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_E02)
            right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_E02)
            array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFEL_input), width=lwidth_FE, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FEL, FEH)))
            left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_E03)
            right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_E03)
            array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFEL_input), width=lwidth_FE, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FEL, FEH)))
            left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_E04)
            right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_E04)
            array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFEL_input), width=lwidth_FE, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FEL, FEH)))
			
            left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_E05)
            right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_E05)
            array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFEL_input), width=lwidth_FE, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FEL, FEH)))
            left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_E06)
            right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_E06)
            array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFEL_input), width=lwidth_FE, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FEL, FEH)))
            left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_E07)
            right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_E07)
            array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFEL_input), width=lwidth_FE, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FEL, FEH)))
            left_val  := interp(line.get_price(line_fc_down, left), line.get_price(line_fc_up, left)	, fib_E08)
            right_val := interp(line.get_price(line_fc_down, right), line.get_price(line_fc_up, right)	, fib_E08)
            array.push(fibs, line.new(left, left_val, right, right_val, style=f_getLineStyle(ppstyleFEL_input), width=lwidth_FE, color=color.from_gradient(right_val, line.get_price(line_fc_down, right), line.get_price(line_fc_up, right), FEL, FEH)))