Stochastic Guppy
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//Derived from TradingView's built-in Stochastic indicator. Switched from SMA to EMA and applied Guppy (GMMA) indicator short and long term periods.
// © jacasanare


//@version=5
indicator(title="Stochastic Guppy EMA", shorttitle="StochGuppy EMA", format=format.price, precision=2, timeframe="", timeframe_gaps=true)

periodK = input.int(14, title="%K Length", minval=1)
smoothK = input.int(1, title="%K Smoothing", minval=1)


k = ta.ema(ta.stoch(close, high, low, periodK), smoothK)
d1 = ta.ema(k, 3)
d2 = ta.ema(k, 5)
d3 = ta.ema(k, 8)
d4 = ta.ema(k, 10)
d5 = ta.ema(k, 12)
d6 = ta.ema(k, 15)
d7 = ta.ema(k, 30)
d8 = ta.ema(k, 35)
d9 = ta.ema(k, 40)
d10 = ta.ema(k, 45)
d11 = ta.ema(k, 50)
d12 = ta.ema(k, 60)


plot(k, title="%K", color=#FF6D00)
plot(d1, title="%D1", color=#FF6D00)
plot(d2, title="%D2", color=#FF6D00)
plot(d3, title="%D3", color=#FF6D00)
plot(d4, title="%D4", color=#FF6D00)
plot(d5, title="%D5", color=#FF6D00)
plot(d6, title="%D6", color=#FF6D00)
plot(d7, title="%D7", color=#2962FF)
plot(d8, title="%D8", color=#2962FF)
plot(d9, title="%D9", color=#2962FF)
plot(d10, title="%D10", color=#2962FF)
plot(d11, title="%D11", color=#2962FF)
plot(d12, title="%D12", color=#2962FF)


h0 = hline(80, "Upper Band", color=#787B86)
hline(50, "Middle Band", color=color.new(#787B86, 50))
h1 = hline(20, "Lower Band", color=#787B86)
fill(h0, h1, color=color.rgb(33, 150, 243, 90), title="Background")