Kijun Trend Indicator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TheSocialCryptoClub info@thesocialcrypto.club

//@version=5
indicator("Kijun Trend Indicator", overlay=true)


// input
myline_periods = input.int(defval=26, title="Lenght")
myline_type = input.string(defval="Kijun", options=["Kijun", "SMA", "EMA"], title="Type")


// default myline color
var myline_color = color.black

// default line is Kijun
myline = math.avg(ta.lowest(low, myline_periods),ta.highest(high, myline_periods))
// or SMA
myline := myline_type == "SMA" ? ta.sma(close,myline_periods) : myline
// or EMA
myline := myline_type == "EMA" ? ta.ema(close,myline_periods) : myline

// filter conditions
long  =  low[1]>myline[1] and low[2]>myline[2] and low[3] <= myline[3]
short =  high[1]<myline[1] and high[2]<myline[2] and high[3]>= myline[3]

// color the line
myline_color := long ? color.blue : myline_color
myline_color := short ? color.red : myline_color

// plot

plot(myline, color=myline_color, linewidth=2, title="Kijun Trend Indicator")
