WU Sahm Recession Indicator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © WealthUmbrella

//@version=5
indicator("WU Sahm Recession Indicator (Work on Monthly)")
UNRate=request.security("UNRATE", "M", close)
UNRate3M=ta.sma(UNRate,3)
UNRateMin12M=ta.lowest(UNRate,12)+0.5


plot(timeframe.ismonthly? UNRate3M:na,"Signal line",color=color.blue)
plot(timeframe.ismonthly? UNRateMin12M:na,"Threshold line",color=color.red)
plot(not timeframe.ismonthly? 0:na,"Threshold line",color=color.red)



signal=(UNRate3M>UNRateMin12M) and (UNRate3M[1]<UNRateMin12M[1])
//plotshape(not timeframe.ismonthly and signal, text='Put the chart in Monthly please', location = location.belowbar, textcolor=color.white,color=color.green, style=shape.labelup,size=size.large)
bgcolor((UNRate3M==UNRateMin12M ) and timeframe.ismonthly? color.new(color.yellow,50):na)
bgcolor((UNRate3M>UNRateMin12M ) and timeframe.ismonthly? color.new(color.red,50):na)
bgcolor((UNRate3M<UNRateMin12M) and timeframe.ismonthly ? color.new(color.green,50):na)
//bgcolor(signal ? color.new(color.blue,50):na)


alertcondition(signal, title = "Recession", message ="Incomming recession")
