FiboBars Extended
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CapitalizatorUA

//@version=5
indicator("FiboBars Extended", overlay=true)
int Period = input.int(title= "Period", defval=7, minval=1)
float hgst = ta.highest(high,Period)
float lwst = ta.lowest(low,Period)
level = input.float(title="Level", defval=0.236, options=[0.000, 0.236, 0.382, 0.500, 0.618, 0.764, 1.000, 1.382, 1.618])

int trend = 0

int trend1 =if ((trend[1]>=0) and (((hgst-lwst)*level)<(close[0])-lwst))
    1
else
    -1

int trend2 =if(trend[1]<=0)and((hgst-lwst)*level<(hgst-close[0]))
    -1
else
    1
    
trend:=if (open[0]>close[0])
    trend1
else
    trend2

barcolor(trend>0 ? #008000 : #ffcccb)
