OPEN-SOURCE SCRIPT
Macro Risk Regime

# Macro Risk Regime — Real-Yield Momentum + Inflation Pulse
## What it does
This indicator answers one question: **is the real-rate backdrop a tailwind or a headwind for risk assets right now?**
It reads the regime off the *direction* of the 10-year real yield — arguably the single most reliable macro driver of risk-asset financial conditions — and surrounds it with a realized-inflation "pulse" that tends to lead the real yield. So you can often see a turn building in inflation before the regime itself flips.
## What it plots
- **Amber line** — the 10-year real yield (FRED: DFII10, the 10Y TIPS yield).
- **White line** — its trend (a moving average over the lookback you set).
- **Shading** — green when the real yield is *below* its trend (real rates falling = easing = **RISK-ON**); red when *above* (rising = tightening = **RISK-OFF**).
The premise: falling real yields ease financial conditions and support risk; rising real yields tighten them and pressure risk. **Direction matters more than level.** This is what captured the deeply negative, falling real yields of 2020–21 (risk-on, even as inflation rose) and the sharp real-yield spike of 2022 (risk-off) — turns that an inflation-level signal alone would have missed.
## The table ("MACRO RISK")
- **Risk Regime** — the headline. The value is the real yield's gap to its trend; the status is RISK-ON (below trend, easing) or RISK-OFF (above trend, tightening).
- **YoY CPI** — trailing headline inflation, for reference. It's the input to the rows below.
- **3m Ann** — realized inflation's last-three-month annualized pace, tagged COOLING / STEADY / HEATING versus the 12-month trend. Your near-term inflation momentum.
- **Surprise\*** — the latest month's annualized pace minus the trailing 3-month pace: UPSIDE (accelerating), DOWNSIDE (decelerating), or IN LINE. See the note below on the asterisk.
- **Real−Priced** — trailing YoY CPI minus the 10-year breakeven (FRED: T10YIE): where realized inflation sits relative to what the market has priced.
- **Trend vs Priced** — realized 3-month pace minus the breakeven: whether the recent inflation run-rate is HOT or COOL versus what's priced. This is the forward-looking tactical read — realized cooling *below* what's priced is the disinflation-confirming signal that tends to pull real yields, and the regime, lower.
## How to use it
1. **Read the shading as the regime.** Green = real-rate tailwind, red = headwind. That's your macro backdrop in one glance.
2. **Use the inflation pulse as the leading tell.** Disinflation showing up first in the pulse (COOLING, DOWNSIDE surprise, COOL vs PRICED) tends to lead real yields lower and flip the regime green; accelerating inflation does the reverse. The pulse often turns before the shading does.
3. **Mind the divergences — they're the point.** When the regime is red but your asset is rising anyway, the move is running on something *other* than real-rate easing — liquidity, flows, an idiosyncratic catalyst — which is a less macro-confirmed, more fragile advance. When the regime and price agree, that's higher conviction. The divergences are the most useful information the tool gives you, not a defect.
4. **Tune the trend length.** Shorter = more responsive and more whipsaw; longer = a smoother, slower regime. The default (100 trading days, ~5 months) is a reasonable middle. The moving average is computed on daily data, so the lookback means the same thing regardless of your chart's timeframe.
Add it to whatever symbol you're analyzing and read your asset against the macro backdrop.
## Settings
- **Risk-Regime Trend Length** — lookback for the real-yield trend (default 100 trading days).
- **Realized-vs-Priced Band** — sensitivity for the HOT / COOL vs PRICED flag (default 0.25%).
- **Surprise Band** — sensitivity for the UPSIDE / DOWNSIDE flag (default 0.5% annualized).
## Methodology and honest limitations
- **It is the real-rate slice of financial conditions plus an inflation pulse — not a full multi-factor financial-conditions index.** It deliberately leaves out credit spreads, the dollar, and equity volatility. It's strongest as the rates/inflation lens; pair it with those other inputs for a complete picture rather than treating it as a standalone everything-gauge.
- **"Surprise" is a momentum proxy, not a consensus surprise.** It compares the latest print to the recent run-rate, because there is no economist-estimate feed available in Pine. So it answers "is inflation accelerating or decelerating off its recent pace," which is related to — but not the same as — "did it beat forecasts." The asterisk in the table marks this.
- **It is a trend/momentum signal, so it can whipsaw** when real yields chop sideways around their average. In those stretches, lean on your other gauges.
- **History starts in 2003.** The real yield and everything referencing breakevens (Real−Priced, Trend vs Priced) begin when TIPS/breakeven data begins; earlier bars read n/a.
## Data
All series are pulled live from FRED via `request.security`: DFII10 (10-year TIPS real yield), T10YIE (10-year breakeven inflation), and CPIAUCSL (CPI). Nothing is hard-coded or hidden — the regime and every table value are computed from these public series.
## Disclaimer
For educational and informational purposes only. This is not investment advice or a recommendation to buy or sell any asset. Markets involve risk; do your own research.
## What it does
This indicator answers one question: **is the real-rate backdrop a tailwind or a headwind for risk assets right now?**
It reads the regime off the *direction* of the 10-year real yield — arguably the single most reliable macro driver of risk-asset financial conditions — and surrounds it with a realized-inflation "pulse" that tends to lead the real yield. So you can often see a turn building in inflation before the regime itself flips.
## What it plots
- **Amber line** — the 10-year real yield (FRED: DFII10, the 10Y TIPS yield).
- **White line** — its trend (a moving average over the lookback you set).
- **Shading** — green when the real yield is *below* its trend (real rates falling = easing = **RISK-ON**); red when *above* (rising = tightening = **RISK-OFF**).
The premise: falling real yields ease financial conditions and support risk; rising real yields tighten them and pressure risk. **Direction matters more than level.** This is what captured the deeply negative, falling real yields of 2020–21 (risk-on, even as inflation rose) and the sharp real-yield spike of 2022 (risk-off) — turns that an inflation-level signal alone would have missed.
## The table ("MACRO RISK")
- **Risk Regime** — the headline. The value is the real yield's gap to its trend; the status is RISK-ON (below trend, easing) or RISK-OFF (above trend, tightening).
- **YoY CPI** — trailing headline inflation, for reference. It's the input to the rows below.
- **3m Ann** — realized inflation's last-three-month annualized pace, tagged COOLING / STEADY / HEATING versus the 12-month trend. Your near-term inflation momentum.
- **Surprise\*** — the latest month's annualized pace minus the trailing 3-month pace: UPSIDE (accelerating), DOWNSIDE (decelerating), or IN LINE. See the note below on the asterisk.
- **Real−Priced** — trailing YoY CPI minus the 10-year breakeven (FRED: T10YIE): where realized inflation sits relative to what the market has priced.
- **Trend vs Priced** — realized 3-month pace minus the breakeven: whether the recent inflation run-rate is HOT or COOL versus what's priced. This is the forward-looking tactical read — realized cooling *below* what's priced is the disinflation-confirming signal that tends to pull real yields, and the regime, lower.
## How to use it
1. **Read the shading as the regime.** Green = real-rate tailwind, red = headwind. That's your macro backdrop in one glance.
2. **Use the inflation pulse as the leading tell.** Disinflation showing up first in the pulse (COOLING, DOWNSIDE surprise, COOL vs PRICED) tends to lead real yields lower and flip the regime green; accelerating inflation does the reverse. The pulse often turns before the shading does.
3. **Mind the divergences — they're the point.** When the regime is red but your asset is rising anyway, the move is running on something *other* than real-rate easing — liquidity, flows, an idiosyncratic catalyst — which is a less macro-confirmed, more fragile advance. When the regime and price agree, that's higher conviction. The divergences are the most useful information the tool gives you, not a defect.
4. **Tune the trend length.** Shorter = more responsive and more whipsaw; longer = a smoother, slower regime. The default (100 trading days, ~5 months) is a reasonable middle. The moving average is computed on daily data, so the lookback means the same thing regardless of your chart's timeframe.
Add it to whatever symbol you're analyzing and read your asset against the macro backdrop.
## Settings
- **Risk-Regime Trend Length** — lookback for the real-yield trend (default 100 trading days).
- **Realized-vs-Priced Band** — sensitivity for the HOT / COOL vs PRICED flag (default 0.25%).
- **Surprise Band** — sensitivity for the UPSIDE / DOWNSIDE flag (default 0.5% annualized).
## Methodology and honest limitations
- **It is the real-rate slice of financial conditions plus an inflation pulse — not a full multi-factor financial-conditions index.** It deliberately leaves out credit spreads, the dollar, and equity volatility. It's strongest as the rates/inflation lens; pair it with those other inputs for a complete picture rather than treating it as a standalone everything-gauge.
- **"Surprise" is a momentum proxy, not a consensus surprise.** It compares the latest print to the recent run-rate, because there is no economist-estimate feed available in Pine. So it answers "is inflation accelerating or decelerating off its recent pace," which is related to — but not the same as — "did it beat forecasts." The asterisk in the table marks this.
- **It is a trend/momentum signal, so it can whipsaw** when real yields chop sideways around their average. In those stretches, lean on your other gauges.
- **History starts in 2003.** The real yield and everything referencing breakevens (Real−Priced, Trend vs Priced) begin when TIPS/breakeven data begins; earlier bars read n/a.
## Data
All series are pulled live from FRED via `request.security`: DFII10 (10-year TIPS real yield), T10YIE (10-year breakeven inflation), and CPIAUCSL (CPI). Nothing is hard-coded or hidden — the regime and every table value are computed from these public series.
## Disclaimer
For educational and informational purposes only. This is not investment advice or a recommendation to buy or sell any asset. Markets involve risk; do your own research.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน