OPEN-SOURCE SCRIPT

Market Euphoria Index v2 - MEI - Predict Market Tops & Bottoms

928
The Market Euphoria Index v2 (MEI) is a 0–100 macro composite designed for the MONTHLY chart of SPX or the Nasdaq Composite (weekly also supported). It measures the cumulative buildup of the conditions that have historically surrounded major cycle tops and bottoms — not price alone, but the collision of euphoria (extension, sustained complacency) with late-cycle stress (profit stagnation, claims turning, curve dynamics, tight policy).

HOW TO READ IT
  • Above 80 — Extreme euphoria: the historical top zone
  • Above 65 — Euphoria warning: late-cycle, tighten risk
  • 35–65 — Neutral
  • Below 35 — Fear: opportunity zone
  • Below 20 — Extreme fear: the historical bottom zone

Confirmation markers add a timing layer on top of the regime reading: a red triangle prints when MEI is in the euphoria zone AND monthly RSI shows a bearish divergence (higher price, lower momentum). A green triangle prints when MEI is in the fear zone AND either monthly RSI is washed out or initial jobless claims roll over from cycle highs — historically one of the tightest bottom signals available (claims peaked within weeks of the March 2009 and March 2020 lows).

THE 8 COMPONENTS (weights adjustable)
  1. Price extension vs 5-year MA (22%) — blended with a 15-year percentile rank so each era is judged against its own norms
  2. Yield curve un-inversion clock (18%) — tops historically cluster 0–12 months after un-inversion; includes a resolve gate so the clock disarms once the cycle has clearly broken (heavy Fed cuts, price under its 5-year MA, or claims spiking)
  3. Corporate profits, ECONOMICS:USCPR (15%) — profits stagnated or declined ahead of the recession-driven bears (1997→2000, 2006→2007); deep decline with an improving second derivative scores as bottom conditions
  4. Jobless claims cycle, ECONOMICS:USIJC (15%) — trough-and-turn off cycle lows = pre-top; spike-and-rollover = bottom
  5. VIX 12-month average (10%) — sustained complacency, not spot readings
  6. Inflation re-acceleration (8%)
  7. Real rate stress (6%) — deflation-guarded so 2009-style CPI collapses read as fear, not stress
  8. Fed cycle position (6%)


All rolling windows are computed at native monthly/quarterly/weekly resolution, so the math is correct on any chart timeframe. Missing history (VIX pre-1990, claims pre-1967, curve pre-1976 falls back to 10Y minus Fed Funds) is handled by dynamic weight renormalization — the composite extends back decades using whatever components exist, and the table shows how much weight is live at any point.

LIMITATIONS — READ BEFORE USING
Economic data publishes with a lag and gets revised, so real-time signals arrive later than a historical replay suggests. This framework targets recession-driven cycles: it structurally cannot anticipate exogenous shocks (2020) and only partially captures rate-shock bears (2022). The 2022–24 curve inversion that resolved without a recession is a live example of a component false positive — which is why no single component, including the curve, should be read in isolation. This is a regime gauge, not a precision timer, and nothing here is financial advice. Always combine with your own risk management.

Alerts are included for all threshold crossings and both confirmation signals. Feedback welcome — especially observations from earlier cycles.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.