Smooth Stochastic and RSI Combo
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © peacefulLizard50262

//@version=5
indicator("Stochastic and RSI", "SRSI")
rsi_length = input.int(14, "RSI Length")
sto_length = input.int(14, "Stochastic Length")
smoothing  = input.int(9, "Smoothing")
rsi = (ta.rsi(ta.wma(close, smoothing), rsi_length) / 100) * 100
sto = (ta.sma(ta.stoch(ta.wma(close, smoothing), ta.wma(high, smoothing), ta.wma(low, smoothing), sto_length), smoothing) / 100) * 100
// plotbar(rsi, math.max(rsi, sto), math.min(rsi, sto), sto, color = math.avg(rsi, sto) > math.avg(rsi[1], sto[1]) ? color.green : color.red)
r = plot(rsi, "RSI", color.red)
s = plot(sto, "Stochastic", color.green)
// fill(r, s, color =  math.avg(rsi, sto) > math.avg(rsi[1], sto[1]) ? color.green : color.red)

hline(50)
up = plot(75, color = color.gray)
dn = plot(25, color = color.gray)

fill(up, dn, color.new(color.blue, 95))
fill(up, r, color = rsi > 75 ? color.new(color.orange, 80) : na)
fill(up, s, color = sto > 75 ? color.new(color.orange, 80) : na)
fill(dn, r, color = rsi < 25 ? color.new(color.orange, 80) : na)
fill(dn, s, color = sto < 25 ? color.new(color.purple, 80) : na)