1. Home
  2. ThinkorSwim Indicators
  3. How To Highlight Recessions on ThinkorSwim Chart

How To Highlight Recessions on ThinkorSwim Chart

This indicator automatically highlights periods of U.S recession on your ThinkorSwim chart.

The data comes from the FRED’s USRECD time series.

A value of 1 denotes a recessionary phase on the FRED’s Peak through the Trough chart, whereas a value of 0 shows an expansionary period.

Based on the data above, the last time we had a recession was from March 2nd, 2020 – April 30th, 2020.

ThinkorSwim U.S Recession Highlighter

# Indicator's Name: U.S Recession Highlighter
# Developer: Melvin C.
# Version: 1.0.0
# URL: https://thinkscript101.com/highlight-recessions-thinkorswim-chart/

def Data = close("USRECD:FRED");
def recession_h = if Data == 1 then Highest(high,35) else double.nan;
def recession_l = if Data == 1 then Lowest(low,35) else double.nan;
AddCloud(recession_h, recession_l, color.orange);

This indicator is helpful for testing and comparison purposes. One way to use it is by adding the indicator to your S&P 500 Index chart.

It will enable you to analyze how certain indicators or trading strategies have performed before, during, and after each U.S. recession period.

Unlock the Power of ThinkorSwim

Get the latest news and updates on TD Ameritrade, ThinkorSwim indicators, thinkScript tutorials, and trading strategies delivered straight to your inbox every week.

We don’t spam! Unsubscribe at anytime.

One thought on “How To Highlight Recessions on ThinkorSwim Chart

  1. Very useful script and nice highlighting visualization method!
    The NBER has one definition of a recession, while there is a simpler definition which is “2 or more periods of negative GDP growth”. Sometimes they don’t agree with each other, such as in 2022. Have you considered writing one of these to track the other definition as well?

Leave a Reply

Your email address will not be published. Required fields are marked *