OPEN-SOURCE SCRIPT
Sector Alert Signals

This Pine Script v6 indicator is a Macro Regime & Sector Rotation Engine. It synthesizes inter-market relationships across 17+ tickers to detect structural shifts in the US equity market that are often invisible on a single-asset chart.
📊 Executive Summary
It utilizes Z-score normalization, volatility-adjusted performance, and ratio analysis to identify 9 distinct macro scenarios. By monitoring the flow of "Smart Money" between defensive and cyclical sectors, the script provides real-time alerts on regime transitions, liquidity cycles, and credit stress.
🛠 Core Macro Scenarios
The engine monitors the following regimes:
1. Risk-On / Risk-Off (XLY/XLP)
Macro Divergence: Identifies when Consumer Discretionary (XLY) leads Staples (XLP) while SPY remains hesitant—a classic "early cycle" recovery signal.
Bubble Alert: Detects extreme greed when SPY is overbought and the XLY/XLP ratio hits a +2.0 Z-score.
2. Monetary Policy & Rate Sensitivity (XLK/XLF)
Rate Cut Front-run: Detects aggressive tech bidding paired with financial weakness, signaling market anticipation of easing.
Growth-to-Value Rotation: Confirms structural shifts when Tech retreats while Financials and Energy surge.
3. Inflation & Reflation Logic
Reflation Trade: Flags "Bond Proxies" (Utilities/Real Estate) plunging while "Hard Assets" (Energy/Metals) surge.
4. Systemic Risk & Credit Stress
KRE Liquidity Collapse: Monitors the spread between Regional Banks (KRE) and Diversified Financials (XLF). A widening negative spread during price drops signals structural credit tightening.
Small Cap Stress: Tracks IWM/SPY divergence as a canary in the coal mine for liquidity withdrawal.
5. Volatility & Liquidity Regimes
High-Vol Leaders: Identifies sectors showing "True Strength" (Performance / Volatility) even when the VIX is > 20.
Liquidity Party: Detects synchronized "High Beta" explosions (SOXX, IGV, XBI, CLOU) indicative of FOMO-driven liquidity peaks.
6. Market Breadth (RSP/SPY)
Concentration Risk: Uses the Equal-Weight vs. Cap-Weight Z-score to alert when the market is narrowing (dangerous) or broadening (healthy).
📊 Executive Summary
It utilizes Z-score normalization, volatility-adjusted performance, and ratio analysis to identify 9 distinct macro scenarios. By monitoring the flow of "Smart Money" between defensive and cyclical sectors, the script provides real-time alerts on regime transitions, liquidity cycles, and credit stress.
🛠 Core Macro Scenarios
The engine monitors the following regimes:
1. Risk-On / Risk-Off (XLY/XLP)
Macro Divergence: Identifies when Consumer Discretionary (XLY) leads Staples (XLP) while SPY remains hesitant—a classic "early cycle" recovery signal.
Bubble Alert: Detects extreme greed when SPY is overbought and the XLY/XLP ratio hits a +2.0 Z-score.
2. Monetary Policy & Rate Sensitivity (XLK/XLF)
Rate Cut Front-run: Detects aggressive tech bidding paired with financial weakness, signaling market anticipation of easing.
Growth-to-Value Rotation: Confirms structural shifts when Tech retreats while Financials and Energy surge.
3. Inflation & Reflation Logic
Reflation Trade: Flags "Bond Proxies" (Utilities/Real Estate) plunging while "Hard Assets" (Energy/Metals) surge.
4. Systemic Risk & Credit Stress
KRE Liquidity Collapse: Monitors the spread between Regional Banks (KRE) and Diversified Financials (XLF). A widening negative spread during price drops signals structural credit tightening.
Small Cap Stress: Tracks IWM/SPY divergence as a canary in the coal mine for liquidity withdrawal.
5. Volatility & Liquidity Regimes
High-Vol Leaders: Identifies sectors showing "True Strength" (Performance / Volatility) even when the VIX is > 20.
Liquidity Party: Detects synchronized "High Beta" explosions (SOXX, IGV, XBI, CLOU) indicative of FOMO-driven liquidity peaks.
6. Market Breadth (RSP/SPY)
Concentration Risk: Uses the Equal-Weight vs. Cap-Weight Z-score to alert when the market is narrowing (dangerous) or broadening (healthy).
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน