Sebastine Trend Catcher
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sebastinecc

//@version=5
indicator("Sebastine Trend Catcher")
len=input(5)
o=ta.ema(open,len)
c=ta.ema(close,len)
h=ta.ema(high,len)
l=ta.ema(low,len)
haclose = (o+h+l+c)/4
haopen = o // initialize haopen variable
haopen := na(haopen[1]) ? (o + c)/2 : (haopen[1] + haclose[1]) / 2
hahigh = math.max (h, math.max(haopen,haclose))
halow = math.min (l, math.min(haopen,haclose))
len2=input(5)
o2=ta.ema(haopen, len2)
c2=ta.ema(haclose, len2)
h2=ta.ema(hahigh, len2)
l2=ta.ema(halow, len2)

// calculate Sancho indicator
sebastine = ((c2 / o2) - 1) * 100




// plot the Sebastine, signal, upper and lower bands
color_sebastine = sebastine >= 0 ? color.green : color.red

plot(sebastine, color=color_sebastine, linewidth=2, title="sebastine",style=plot.style_stepline)
hline(0, title="Zero Line", color=color.white, linestyle=hline.style_dashed, linewidth=2)