Orion:Supertrend Hybrid
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © priceprophet

//@version=5
indicator("Orion:Supertrend Hybrid", overlay=true, timeframe="", timeframe_gaps=true)

len = input.int(title="Length", defval = 12)

atrPeriod = input(10, "ATR Length")
factor = input.float(3.0, "Factor", step = 0.01)

HH = ta.highest(high,len)
LL = ta.lowest(low,len)



[supertrend, direction] = ta.supertrend(factor, atrPeriod)

mean = direction < 0 ? supertrend + (HH - supertrend)/2 : supertrend - (supertrend - LL)/2



bodyMiddle = plot(mean,color=color.yellow) //, display=display.none
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red, style=plot.style_linebr)

fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false)
