The last seven recessions were preceded by an inverted yield curve. This is preset to the 2 year and 10 year US bond, weekly, but you can set it to whatever you like.
Published with source code for anyone to modify. This is the first in a series of indicators I intend to publish as a package of economic recoverty/recession symptom indicators.