Recession And Bull Run Warning
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © chinmaysk1

//@version=5
indicator("Recession Warning",overlay = true)

// EMA values
ema1 = ta.ema(close,5)
ema2 = ta.ema(close,21)

// Getting moving averages from UNEMPLOY
low_ema = request.security('UNEMPLOY', 'D', ema1)
high_ema = request.security('UNEMPLOY', 'D', ema2)

// Check When Unemploy Avgs Could Cross
cross = ((102 * high_ema[1]) - (22 * low_ema[1])) / 80

// Signals and plots
warning_true = low_ema[2] < high_ema[2] and low_ema >= high_ema
plotshape(warning_true, "Recession Warning", style = shape.circle, location = location.abovebar, color = color.red, size = size.small)

bullrun = low_ema >= high_ema and low_ema[2] > low_ema
plotshape(bullrun, "Bullrun Incoming", style = shape.circle, location = location.belowbar, color = color.green, size = size.small)


current_unemploy = request.security('UNEMPLOY', 'D', close)
projection = label.new(bar_index + 10, close, style = label.style_label_left, color = color.rgb(15,15,15))
label.set_textcolor(projection, color.white)
label.set_textalign(projection, text.align_left)
label.delete(projection[1])
if low_ema < high_ema
    label.set_text(projection, "Current Unemployment: " + str.tostring(current_unemploy) + "\nRecession When Unemployment Reaches " + str.tostring(math.round(cross)))

else
    label.set_text(projection, "Current Unemployment: " + str.tostring(current_unemploy) + "\nBull Run When Unemployment Drops To " + str.tostring(math.round(cross)) + "\n(Ignore If Green Dot Signalled)")

