OPEN-SOURCE SCRIPT

US Recessions (NBER)

This indicator is designed to replace the US Recessions indicator.
Unfortunately, the original indicator is now broken, and the author is not responding: tradingview.com/v/csfFrTe4/ .

There are other similar indicators, but they are not based on live data and either show non-officially recognized recessions or fail to display all officially recognized recessions.

This indicator shades US recession periods based on live monthly data from USREC. It highlights all officially recognized US recessions according to the NBER and will automatically shade any future recessions when they occur. The indicator works across all timeframes, correctly shading recessions whether you are viewing a 30-minute, 2-hour, daily, weekly, or any other chart timeframe.

Warning & Risks:
This indicator uses the barmerge.lookahead_on option to correctly handle monthly recession data from USREC. The purpose of this setting is to ensure that the monthly data points are applied retroactively to the corresponding bars on the chart. However, this means that while past recession periods are accurately shaded, the script is effectively displaying data from future candles and plotting it backward onto the chart.

This behavior does not introduce a “future leak” in the traditional sense—since USREC data is backward-looking and the current month always remains non-recessionary until officially confirmed. Nonetheless, it can cause confusion, as users may see recession periods shaded retroactively only after the data becomes available. Therefore, the current month will always appear non-recessionary until the next data point is released, and historical recession periods may be adjusted after the fact.
Cyclesnberrecessionrecessionsusrecessionusrecessions

開源腳本

在真正的TradingView精神中,這個腳本的作者以開源的方式發佈,這樣交易員可以理解和驗證它。請向作者致敬!您可以免費使用它,但在出版物中再次使用這段程式碼將受到網站規則的約束。 您可以收藏它以在圖表上使用。

想在圖表上使用此腳本?

免責聲明