OPEN-SOURCE SCRIPT
Aktualisiert

Macro Environment Dashboard SPX/Nasdaq Levels

966
============================================================
Macro Environment Dashboard SPX/Nasdaq Levels

This indicator aims to show an actual snapshot of the current macro situation, so you can estimate what to expect from the day.

This is a result of a long AI conversation, in order to gather market principles into a usable dashboard. Hope you find it useful.

Purpose
Provides a structured macro environment dashboard for equity index trading, combining liquidity, volatility, credit, and trend signals into a single regime framework. It automatically determines support and resistance levels, evaluates market risk conditions, and generates contextual alerts for potential breakout or breakdown events.

The tool is designed for discretionary traders, systematic traders, and macro-aware technical traders who want to align execution decisions with the prevailing macro regime.

---

1. Market Principles the Script Is Based On

The indicator is built on a multi-factor macro model. It assumes that equity index behavior is primarily driven by liquidity conditions, financial stress signals, interest rates, volatility, and trend structure.

Core Principle: Markets Move With Liquidity

When liquidity expands:

* risk assets tend to rise
* volatility tends to fall
* credit conditions improve

When liquidity contracts:

* risk assets tend to weaken
* volatility tends to rise
* financial stress increases

The Model Uses Eight Core Signals

Liquidity
Measures global central bank balance sheets relative to liquidity drains.

Liquidity Delta
Measures short-term liquidity changes from funding sources.

Dollar (DXY)
A stronger dollar tightens global financial conditions.

10Y Yield
Higher yields increase discount rates and pressure equities.

Credit
Credit spreads reflect financial system health.

VIX
Market volatility represents risk perception.

SPX Trend
Trend direction of the S&P 500.

Nasdaq Trend
Trend direction of the Nasdaq index.

These signals are combined into a weighted score that determines the market regime.

Regime Model

STRONG RISK ON
High liquidity alignment and positive market conditions.

RISK ON
Supportive macro environment but not fully aligned.

NEUTRAL
Mixed signals or transitional environment.

RISK OFF
Defensive environment with elevated risk.

---

2. Table Rows — All Possible Values and Meaning

Liquidity

Injection
Liquidity is expanding.
Typically bullish for equities.

Drain
Liquidity is contracting.
Typically bearish for equities.

Impact Interpretation
Injection → upward price pressure
Drain → downward price pressure

---

Liq Delta

Improving
Short-term liquidity is increasing.

Deteriorating
Short-term liquidity is decreasing.

Impact Interpretation
Improving → short-term support
Deteriorating → short-term risk

---

Dollar

Weak USD
Financial conditions are easing.

Strong USD
Financial conditions are tightening.

Impact Interpretation
Weak USD → risk assets supported
Strong USD → risk assets pressured

---

10Y Yield

Falling
Discount rates are declining.

Rising
Discount rates are increasing.

Impact Interpretation
Falling → equities supported
Rising → equities pressured

---

Credit

Healthy
Credit markets are stable.

Stress
Credit risk is increasing.

Impact Interpretation
Healthy → supportive risk environment
Stress → elevated financial risk

---

VIX

Low Vol
Market risk perception is low.

High Vol
Market risk perception is elevated.

Impact Interpretation
Low Vol → stable conditions
High Vol → unstable conditions

---

SPX Trend

Bullish
Short-term trend is upward.

Bearish
Short-term trend is downward.

---

Nasdaq Trend

Bullish
Short-term trend is upward.

Bearish
Short-term trend is downward.

---

Selected

Bullish
The currently selected execution market trend is positive.

Bearish
The currently selected execution market trend is negative.

---

Support 1

Automatically calculated key support level.

Meaning
Primary downside structure level.

Behavior
Break below support indicates potential continuation lower.

---

Resistance 1

Automatically calculated key resistance level.

Meaning
Primary upside structure level.

Behavior
Break above resistance indicates potential continuation higher.

---

Persistence / Risk

Confirmed
The macro regime has persisted for the required number of bars.

Pending
The regime is still forming.

Risk Layer Values

TRENDING
Directional movement is strong and sustained.

CONSOLIDATING
Market is range-bound.

UNSTABLE
Volatility expansion or elevated risk conditions.

Impact Interpretation

TRENDING
Trend continuation likely.

CONSOLIDATING
Breakout risk increasing.

UNSTABLE
Risk management priority.

---

Regime / Score

Displays the macro regime and confidence percentage.

Possible Values

STRONG RISK ON
Score above 75%

RISK ON
Score between 55% and 75%

NEUTRAL
Score between 35% and 55%

RISK OFF
Score below 35%

---

Glyph Symbols


Bullish or supportive signal


Bearish or negative signal


Neutral condition

---

3. Settings Explanation

Auto Detect Market

Automatically determines whether the chart represents:

SPX
or
NASDAQ

If enabled
The script identifies the instrument automatically.

If disabled
Manual selection is used.

---

Manual Market Override

Used only when auto detection is disabled.

Options

SPX
NASDAQ

---

Fast Length

Short-term moving average period.

Used for trend detection.

Typical values

3
5
10

---

Slow Length

Longer moving average period.

Used for trend confirmation.

Typical values

15
20
30

---

Show Dashboard Table

Enables or disables the macro dashboard display.

---

Show Macro Background

Colors the chart background according to the macro regime.

Green
Risk-on environment

Orange
Neutral environment

Red
Risk-off environment

---

Show Support / Resistance Levels

Displays automatically calculated levels.

---

Show S/R Price Labels

Displays price labels to the right of the last bar.

Example

S1: 5120
R1: 5185

---

Levels Mode

Determines how support and resistance are calculated.

Options

Swing
Uses recent highs and lows.

ATR
Uses volatility-based levels.

Pivot
Uses pivot structure detection.

---

Swing Lookback 1

Short-term support/resistance window.

Typical

20

---

Swing Lookback 2

Longer-term support/resistance window.

Typical

50

---

ATR Length

Volatility measurement period.

Typical

14

---

ATR Basis Length

Moving average used as ATR center.

Typical

20

---

ATR Mult 1

Primary volatility distance.

Typical

1.0

---

ATR Mult 2

Secondary volatility distance.

Typical

2.0

---

Pivot Left Bars

Number of bars before pivot.

---

Pivot Right Bars

Number of bars after pivot.

---

Regime Confirmation Bars

Number of bars required to confirm a regime.

Higher value

More stability
Less noise

Lower value

Faster signals
More sensitivity

Typical

3

---

Liquidity Delta Smoothing

Smoothing factor for liquidity change signal.

Typical

3

---

Liquidity Delta Lookback

Historical comparison period.

Typical

5

---

Risk Layer Fast Trend

Short-term trend period.

---

Risk Layer Slow Trend

Longer trend period.

---

Risk Layer Range Length

Range measurement window.

---

Trending Threshold %

Minimum trend strength required.

---

Unstable ATR % Threshold

Volatility threshold for instability detection.

---

Consolidation Range % Threshold

Range size threshold for consolidation detection.

---

4. Use Cases / How To Use

Use Case 1 — Trend Continuation

Conditions

Regime
STRONG RISK ON

Risk Layer
TRENDING

Signal

Price breaks Resistance 1

Interpretation

High-probability continuation setup.

---

Use Case 2 — Breakdown Risk

Conditions

Regime
RISK OFF

Risk Layer
UNSTABLE

Signal

Price breaks Support 1

Interpretation

Downside continuation likely.

---

Use Case 3 — Range Trading

Conditions

Risk Layer
CONSOLIDATING

Signal

Price moves between Support and Resistance.

Interpretation

Mean-reversion environment.

---

Use Case 4 — Early Risk Warning

Conditions

Liquidity
Drain

Credit
Stress

VIX
High Vol

Interpretation

Elevated systemic risk.

Risk management priority.

---

Use Case 5 — Regime Transition

Conditions

Regime
Pending

Interpretation

Market environment changing.

Wait for confirmation.

---

Best Practices

Use the indicator for:

Context
Risk management
Trade confirmation
Market regime identification

Do not use it as:

A standalone entry signal
A prediction tool
A guarantee of market direction

---


Versionshinweise
What's New — MacroDashboard

----------------------------------------------------------------------------

**6 Color Schemes**

Pick your preferred look from the *Table Colour Scheme* input:
- Dark Slate *(original)*
- Deep Navy / Teal
- Warm Charcoal / Gold
- Midnight Purple
- Soft White / Blue
- Warm Ivory / Rose

Every table element — backgrounds, text, glyphs — adapts to the chosen theme.

----------------------------------------------------------------------------

**Cleaner Table Layout**

The dashboard is more compact. The redundant side stripe and the duplicate *Selected* row are gone. The title bar now spans the full width with larger text. The SPX/Nasdaq rows swap automatically so **the active market is always at the bottom** of the signal section.

----------------------------------------------------------------------------

**Smarter Persist Cell**

The persistence indicator now uses **◆** (confirmed) and **◇** (pending) instead of ▲ / •. The diamond shape signals certainty; the *color* tells you the direction. When the regime is still pending, the cell dims to grey so it doesn't mislead you.

----------------------------------------------------------------------------

**Levels That Actually Match Your Chart**

Levels now always compute from the **chart instrument itself** at daily resolution. Previously they were pulled from SPX/NASDAQ cash data, so on CFD or futures charts (NAS100, ES, MNQ…) the levels appeared far off-price. This is now fixed regardless of what instrument you're viewing.

---

**S2 / R2 Are a Distinct Zone**

In Swing mode, S1/R1 cover the *most recent 20 days* and S2/R2 cover the *prior 21–50 day zone* — two genuinely independent areas. Previously both measured from bar 0 and were often identical.

----------------------------------------------------------------------------

**Levels Always Properly Ordered**

R1 is always the *nearer* (lower) resistance and R2 the *further* (higher) one — and vice versa for support — regardless of trend direction or level mode. The previous version could show R2 below current price in a strong uptrend.

----------------------------------------------------------------------------

**Intraday S/R Levels** *(new)*

Enable *Show Intraday S/R Levels* to get a second set of levels built for intraday charts. They only appear on sub-daily timeframes and use distinct colors — **orange** for support, **purple** for resistance — so they never clash with the daily red/green lines.

Four modes to choose from:

1. **Classic Pivot** *(default)* — The standard floor-trader pivot (PP, S1/R1, S2/R2) from yesterday's high, low and close. The most widely watched intraday levels.
2. **Prev Day H/L** — Yesterday's high and low as hard session boundaries, with a 50% range extension projected above and below.
3. **ATR (VWAP basis)** — Session VWAP ± ATR bands, adapting dynamically to the day's volatility.
4. **Swing** — Same layered-zone logic as the daily engine, calculated at your chart's bar resolution.

Labels are prefixed *iS1:*, *iR1:*, *PP:* etc. to keep them separate from daily labels. Break signals and alert conditions are included.

*Tip: to view intraday levels only, enable Show Intraday S/R Levels and uncheck Show Support / Resistance Levels.*
Versionshinweise
## 🔔 What's New

### Regime & Score Alerts

**6 new regime alerts:**
- **Regime Changed** — fires on any confirmed regime transition
- **Regime: Strong Risk On** — fires when regime shifts to Strong Risk On
- **Regime: Risk On** — fires when regime shifts to Risk On
- **Regime: Neutral** — fires when regime shifts to Neutral
- **Regime: Risk Off** — fires when regime shifts to Risk Off

**6 new score threshold alerts:**
- **Score Crossed 75% Up / Down** — Strong Risk On boundary
- **Score Crossed 55% Up / Down** — Risk On boundary
- **Score Crossed 35% Up / Down** — Risk Off boundary

---

### Persistence & Risk Layer Alerts

**3 new persistence alerts:**
- **Regime Persistence Changed** — fires on any Confirmed ↔ Pending transition
- **Regime Persistence: Confirmed** — regime held long enough to be confirmed
- **Regime Persistence: Pending** — regime reverted to unconfirmed state

**4 new risk layer alerts:**
- **Risk Layer Changed** — fires on any volatility regime transition
- **Risk Layer: Trending** — market shifted into trending mode
- **Risk Layer: Consolidating** — market shifted into consolidation
- **Risk Layer: Unstable** — elevated volatility detected

---

### Intraday Level Alerts

**2 new deeper-level alerts** (in addition to existing S1/R1):
- **Intraday Support 2 Breach** — price crossed below iS2
- **Intraday Resistance 2 Break** — price crossed above iR2

Matching chart markers (faded orange / purple triangles) added for iS2 and iR2 breaks.

---

### Alert Message Format

All alert messages now follow the standard format:

`{{ticker}} {{interval}} <description>`

This makes webhook and bot integrations easier — ticker and timeframe are always included automatically.

---

*Total alert conditions available: 24*

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.