FRED Recession Indicator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
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;
 
@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);
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
320 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top