Stochastic Trend mtf
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ahmettetik77

//@version=5
indicator(title="Stochastic Trend mtf", shorttitle="Stoch Trend mtf", format=format.price, precision=2, timeframe="240", timeframe_gaps=false)
neon        = input.bool(title = 'Neon Theme', defval = true)
EMA         = input(true, title='Show EMA Line?')
smoothK     = input.int(8, "K", minval=1)
smoothD     = input.int(3, "D", minval=1)
lengthRSI   = input.int(14, "RSI Length", minval=1)
lengthStoch = input.int(14, "Stochastic Length", minval=1)
src         = input(close, title="RSI Source")
bullcolor   = neon ? #00ffbb : #00b712
bearcolor   = neon ? #ff1100 : #c30010
rsi1        = ta.rsi(src, lengthRSI)
k           = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d           = ta.sma(k, smoothD)

obupper     = plot(100, color = color.new(bearcolor, 0), display = display.none)
oblower     = plot(90, color = color.new(bearcolor, 0), display = display.none)
obmid       = plot(80, display = display.none)
osupper     = plot(10, color = color.new(bullcolor, 30), display = display.none)
oslower     = plot(0, color = color.new(bullcolor, 30), display = display.none)
osmid       = plot(20, color = color.new(bullcolor, 70), display = display.none)
hline(50)
mid         = plot(50, display = display.none, editable = false)

plot1       = plot(k, color = color.new(color.white, 100))
plot2       = plot(EMA and d ? d : na, title='EMA Line', style=plot.style_line, linewidth=2, color=color.rgb(66, 170, 255, 100))
z           = plot(k, color=k> d ? bullcolor : k < d ? bearcolor : color.rgb(27, 26, 26, 60), linewidth=1, title='STC')
fill(z, plot2, k > d ? k : d, k > d ? d : k, k > d ? bullcolor : #00000000, k > d ? #00000000 : bearcolor)
fill(obupper, oblower, color.new(bearcolor, 70))
fill (oblower, obmid, color.new(bearcolor, 85))
fill(osupper, oslower, color.new(bullcolor, 70))
fill(osupper, osmid, color.new(bullcolor, 85))