OPEN-SOURCE SCRIPT
Güncellendi

S&P 500 & Normalized CAPE Z-Score Analyzer

172
This macro-focused indicator visualizes the historical valuation of the U.S. equity market using the CAPE ratio (Shiller P/E), normalized over its long-term average and standard deviations. It helps traders and investors identify overvaluation and undervaluation zones over time, combining both statistical signals and historical context.

💡 Why It’s Useful
This indicator is ideal for macro traders and long-term investors looking to contextualize equity valuations across decades. It helps identify statistical extremes in valuation by referencing the standard deviation of the CAPE ratio relative to its long-term mean. The overlay of S&P 500 price with valuation zones provides a visual confirmation tool for macro decisions or timing insights.

It includes:

✅ Three display modes:
-S&P 500 (color-coded by CAPE valuation zone)
-Normalized CAPE (vs. long-term mean)
-CAPE Z-Score (standardized measure)

🎯 How to Interpret
Dynamic coloring of the S&P 500 price based on CAPE valuation:
🔴 Z > +2σ → Highly Overvalued
🟠 Z > +1σ → Overvalued
⚪ -1σ < Z < +1σ → Neutral
🟢 Z < -1σ → Undervalued
✅ Z < -2σ → Strong Buy Zone

-Live valuation label showing the current CAPE, Z-score, and zone.
-Macro event shading: major historical events (e.g. Great Depression, Oil Crisis, Dot-com Bubble, COVID Crash) are shaded on the chart for context.

✅ Built-in alerts:
CAPE > +2σ → Potential risk zone
CAPE < -2σ → Potential opportunity zone

📊 Use Cases
This indicator is ideal for:
🧠 Macro traders seeking long-term valuation extremes.
📈 Portfolio managers monitoring systemic valuation risk.
🏛️ Long-term investors timing strategic allocation shifts.

🧪 How It Works
CAPE ratio (Shiller PE) is retrieved from Quandl (MULTPL/SHILLER_PE_RATIO_MONTH).

The script calculates the long-term average and standard deviation of CAPE.

The Z-score is computed as:
(CAPE - Mean) / Standard Deviation

Users can switch between:
S&P 500 chart, color-coded by CAPE valuation zones.
Normalized CAPE, centered around zero (historic mean).
CAPE Z-score, showing statistical positioning directly.

Visual bands represent +1σ, +2σ, -1σ, -2σ thresholds.

You can switch between modes using the “Display” dropdown in the settings panel.

📊 Data Sources
CAPE: MULTPL/SHILLER_PE_RATIO_MONTH via Quandl
S&P 500: Monthly close prices of SPX (TradingView data)

All data updated on monthly resolution

This is not a repackaged built-in or autogenerated script. It’s a custom-built and interactive indicator designed for educational and analytical use in macroeconomic valuation studies.
Sürüm Notları
🆕 [Jun 2025] — We've added a warning system to highlight an important behavior:

The normalized CAPE and Z-score calculations in this script depend heavily on the length of historical data available for the selected symbol.

If you're analyzing the S&P 500, make sure to use SPX or any symbol with long historical coverage, or else the statistical interpretation may be misleading due to a shortened lookback period.

A red warning label will now appear automatically when you're not using SPX.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.