- Platform
-
- Thinkorswim
From the original author at https://www.tradingview.com/script/XuspUpEC-Recession-Indicator/
According to the New York Fed, "The yield curve—specifically, the spread between the interest rates on the ten-year Treasury note and the three-month Treasury bil —is a valuable forecasting tool. It is simple to use and significantly outperforms other financial and macroeconomic indicators in predicting recessions two to six quarters ahead."
FRED stands for Federal Reserve Economic Data.
According to the New York Fed, "The yield curve—specifically, the spread between the interest rates on the ten-year Treasury note and the three-month Treasury bil —is a valuable forecasting tool. It is simple to use and significantly outperforms other financial and macroeconomic indicators in predicting recessions two to six quarters ahead."
FRED stands for Federal Reserve Economic Data.

Code:
# FRED Recession Indicator
# Converted from https://www.tradingview.com/script/XuspUpEC-Recession-Indicator/
# Updated 2020-12-28 Barbaros, added percentage probability
#5% → 1.21
#10% → 0.76
#15% → 0.46
#20% → 0.22
#25% → 0.02
#30% → -0.17
#40% → -0.50
#50% → -0.82
#60% → -1.13
#70% → -1.46
#80% → -1.85
#90% → -2.40
declare lower;
input chartType = { default ratio, percentage };
def tenyear_tres = close("DGS10:FRED");
def threemonth_tb = close("DTB3:FRED");
def diff = tenyear_tres - threemonth_tb;
def perc = (-25.896 * diff) + 29.036;
def percLabel = if !isNaN(perc) then perc else percLabel[1];
def diffLabel = if !isNaN(diff) then diff else diffLabel[1];
plot limit;
plot prob;
switch(chartType) {
case ratio:
prob = diffLabel;
limit = 0.02;
case percentage:
prob = percLabel;
limit = 25;
}
AddLabel(yes, "FRED Recession Probability", Color.WHITE);
AddLabel(yes, (if chartType == chartType.percentage then percLabel + "%" else diffLabel + ""), Color.GRAY);
Last edited: