FRED Recession Indicator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
This indicator tries to predict the recession four quarters ahead using the yield curve spread (the spread between the interest rates on the ten-year Treasury note and the three-month Treasury bill). I previously saw some of our members talking about this concept in the Discord chatroom but didn't put much thought into it until recently, I came across this script on TradingView.

The yield curve—specifically, the spread between the interest rates on the ten-year Treasury note and the three-month Treasury bill—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.

More on that here.

The following table is important. Recession Probability Value of Spread.

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

The Recession Indicator below will plot the yield curve spread along with the 25% probability value, which is 0.02. You can refer back to the table above and adjust this probability line based on your liking.

AlXwd6N.png


thinkScript Code

Code:
# FRED Recession Indicator
# Assembled by BenTen at UseThinkScript.com
# Converted from https://www.tradingview.com/script/XuspUpEC-Recession-Indicator/

declare lower;

def tenyear_tres = close("DGS10:FRED");
def threemonth_tb = close("DTB3:FRED");

plot ratio = tenyear_tres - threemonth_tb;
plot value = 0.02;
 

barbaros

Well-known member
VIP
@BenTen I added percentage prob option. Can you check it out.

Python:
# FRED Recession Indicator
# Assembled by BenTen at UseThinkScript.com
# 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;

plot limit;
plot prob;

switch(chartType) {

case ratio:
    prob =  diff;
    limit = 0.02;

case percentage:
    prob = perc;
    limit = 25;

}

AddLabel(yes, "FRED Recession Probability", Color.WHITE);
AddLabel(yes, prob + (if chartType == chartType.percentage then "%" else ""), Color.GRAY);
 

Similar threads

Top