% Above 50 DMA
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © crutchie

//@version=5
indicator("% Above 50 DMA")

//Inputs
exchange = input.string("NYSE", options = ["NYSE", "Nasdaq"])

perc = exchange == "NYSE" ? request.security("MMFI", timeframe.period, close) : request.security("NCFI", timeframe.period, close)

ema1 = ta.ema(perc,5)
ema2 = ta.ema(perc,20)

perccolor = perc > 80 ? color.red : perc < 20 ? color.red : color.black

plot(perc, "Percent", color = perccolor)
plot(ema1, "EMA 1" , color = color.rgb(13, 234, 230), display = display.pane)
plot(ema2, "EMA 2", color = color.blue, display = display.pane)

hline(20, "Danger Zone", color = color.red)
hline(80, "Oversold Zone", color = color.red)

//Background shading signal
signalcolor =  ema1 > ema2 ? color.rgb(76, 175, 79, 90) : color.rgb(255, 82, 82, 92)
bgcolor(signalcolor, title = "Signal Shading")