OPEN-SOURCE SCRIPT
Aggiornato

Macro Return Forecast

475
When the macro environment was similar, what annualized return did the market usually deliver next?

Before using the indicator, make sure your chart is set to any US-market symbol (SPX, QQQ, DIA, etc.).
This requirement is simple: the indicator pulls macro series from US data (yields, TIPS, credit spreads, breadth of US indices).
Because these series are independent from the chart’s price series, the chart symbol itself does not affect the internal calculations.
Any US symbol works, and the output of the model will be identical as long as you are on a US asset with daily, weekly or monthly timeframe.
The plotted price does not matter: the macro engine is fully exogenous to the chart symbol.

1. What the indicator does relative to selected assets

In the settings you choose which market you want to analyze:
- S&P500
- Nasdaq or NQ100
- Dow Jones
- Russell 2000
- US-wide (VTI)
- S&P500 sectors (XLF, XLY, XLP, etc.)

For each one, the indicator loads:
- Its internal breadth series (percentage of constituents above MA200)
- Its price history to compute forward log-returns at multiple horizons
- Its regime position relative to its own MA200 (for bull/bear filtering)

This means the tool is not tied to the chart symbol you display.
If your chart is SPX but the indicator setting is “S&P500 Technology”, the expected return projection is computed for the Technology sector using its own data, not the chart’s data.

You can therefore:
- Visualize macro-driven expected returns for any major US index or sector.
- Compare how different parts of the market historically reacted to similar macro states.
- Switch assets instantly to see which segment historically behaved better in comparable macro conditions.

The indicator becomes an analyzer of macro sensitivity, not a chart-dependent indicator.

2. Method overview

The model answers a statistical question:
“When macro conditions looked like they do today, what forward annualized return did this asset usually deliver?”

To do this it combines four macro pillars:
- Market breadth of the selected asset
- Yield curve slope (US 10Y minus 2Y)
- US credit spread (high yield minus gov)
- US real rate (TIPS 10Y)

It normalizes each metric into a 0–100 score, groups similar historical states into bins, and examines what the asset did next across six horizons (from ~9 months to ~5 years).
This produces a historical map connecting macro states to realized forward returns.

It is not a forecast model.
It is a conditional-distribution estimator: it tells you what has historically happened from similar setups.

3. Why this produces useful insights on assets

For any chosen asset (SPX, Nasdaq, sectors…), the indicator computes:
- Its forward return distribution in similar macro states.
- How often these states occurred (n).
- Whether the macro environment that preceded positive returns in the past resembles today’s.
- Whether the asset tends to be more sensitive or more resilient than the broad index under given macro configurations.
- Whether a given sector historically benefited from specific yield-curve, credit or real-rate environments.

This lets you answer questions such as:
- Does this sector usually outperform in an inverted yield curve environment?
- Does the Nasdaq historically recover strongly after breadth collapses?
- How did the S&P500 behave historically when real rates were this high?
- Is today’s credit-spread environment typically associated with positive or negative forward returns for this index?

These insights are not predictions but statistical context backed by past market behavior.

4. Why the technique is robust (and why it matters)

The engine uses strict, non-optimistic data processing:
- Winsorization of returns to neutralize extreme outliers without deleting information.
- Shrinkage estimators to avoid overfitting when bins contain few occurrences.
- Adaptive or static bounds for scaling macro indicators, ensuring comparability across cycles.
- Inverse-variance weighting of horizons with penalties for horizon redundancy.
- HAC-style adjustments to reduce autocorrelation bias in return estimation.

Each method aims to prevent artificial inflation of expected-return values and to keep the estimator stable even in unusual macro states.

This produces a result that is not “optimistic”, not curve-fit, not dependent on chart tricks, and not sensitive to isolated historical anomalies.

5. What you get as a user

A single clean line:
Expected Annual Return (%)

This line reflects how the chosen asset historically performed after macro environments similar to today’s.
The color gradient and confidence indicator (n) show the density of comparable episodes in history.

This makes the output extremely simple to read:
- High, stable expectation: historically supportive macro environment.
- Low or negative expectation: historically weaker environments.
- Low confidence: the macro state is rare and historical comparisons are limited.

The tool therefore adds context, not signals.
It helps you understand the environment the asset is currently in, based on how markets behaved in similar conditions across US market history.
Note di rilascio
Small bug fixed
Note di rilascio
Major update: Added a macro-based Investment Opportunity score on a 0–10 scale. The script now computes expected annual returns from four key macro factors (market breadth, yield curve slope, credit spreads, and real rates) across multiple horizons, adjusts them for historical risk (upside probability and downside volatility), and evaluates how consistently the factors align in the same direction. These components are combined into a single normalized score, further weighted by signal reliability (sample size), to provide a concise medium/long-term investment opportunity rating.
Note di rilascio
Minor bug fixes. Removed independent sectors that did not yield robust results.
Note di rilascio
This update improves the statistical robustness of the indicator.
Factor weighting is now constrained around strategic baselines, correlations are thresholded to avoid noise-driven shifts, and signal outputs are gated by effective sample size.
Expected return estimates are also stabilized with controlled score compression when data is limited.
Overall, signals are more reliable, less sensitive to noise, and better aligned with medium- to long-term investment use.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.