PROTECTED SOURCE SCRIPT

Sector Rotation Dashboard (Beta)

76
🎯 OVERVIEW

The Sector Rotation Indicator is a comprehensive real-time dashboard that tracks money flow across all 11 S&P 500 sector ETFs and 6 major macro assets. It automatically detects market regimes (Risk-On, Risk-Off, Tech-Led), flags anomalies, and shows you where institutional money is flowing.

Whether you're trading individual stocks, sector ETFs, or managing a portfolio, this indicator tells you:
• Which sectors are leading/lagging (ranked by relative strength)
• What market regime we're in (Risk-On, Risk-Off, Tech-Led, Mixed)
• Where the anomalies are (sectors behaving unexpectedly)
• How confident the signals are (based on cross-sector confirmation)
• What sector ETF the current chart ticker belongs to, if any (with rank and RS%)


🚧 BETA NOTICE

⚠️ This indicator is currently in BETA.

IMPORTANT - ETF Holdings Database:
• The 500+ stock-to-sector mappings are based on actual ETF holdings
• SPDR sector ETFs rebalance quarterly (3rd Friday of Mar/Jun/Sep/Dec)
• Holdings data requires MANUAL updating by the creator after each rebalance
• Users may experience DELAYS in data updates following rebalance dates
• Some newly added or removed stocks may be temporarily misclassified


📊 WHAT IT TRACKS

11 SPDR Sector ETFs:
• XLE (Energy) - Cyclical
• XLF (Financials) - Cyclical
• XLI (Industrials) - Cyclical
• XLY (Consumer Discretionary) - Cyclical
• XLB (Materials) - Cyclical
• XLK (Technology) - Growth
• XLC (Communication Services) - Growth
• XLV (Healthcare) - Defensive
• XLP (Consumer Staples) - Defensive
• XLU (Utilities) - Defensive
• XLRE (Real Estate) - Defensive

6 Macro Assets:
• GLD (Gold) - Safe Haven
• TLT (20+ Year Treasuries) - Safe Haven
• UUP (US Dollar Index) - Currency
• DBC (Commodities) - Risk/Inflation
• EEM (Emerging Markets) - Risk Appetite
• IBIT (Bitcoin) - Speculative


🔥 KEY FEATURES

1️⃣ Real-Time Sector Rankings
• All 11 sectors ranked by Relative Strength (RS) vs SPX
• Dual color coding: Background = RS, Text = Absolute performance
• Trend arrows showing momentum (↑↑, ↑, →, ↓, ↓↓)
• Rank change tracking with configurable alert threshold

2️⃣ Intelligent Regime Detection
• Risk-On: Cyclicals leading (XLE, XLF, XLI, XLY, XLB)
• Risk-Off: Defensives leading (XLV, XLP, XLU, XLRE)
• Tech-Led: Growth dominating (XLK, XLC)
• Mixed: No clear leadership
• High Volatility: Signals unreliable

3️⃣ Anomaly Detection System
• Flags sectors that jump/drop 3+ ranks
• Detects behavioral anomalies (e.g., Energy #1 in Risk-Off)
• High volatility warnings when multiple sectors show extreme moves
• Dynamic tooltips explain WHY each anomaly is flagged

4️⃣ Confidence Scoring
• Counts how many sectors confirm the current regime
• High (7+), Medium (5-6), Low (<5) confidence levels
• Shows exactly which sectors are confirming vs diverging

5️⃣ Current Ticker Classification
• Built-in database of 500+ stock tickers mapped to sector ETFs
• Shows your current chart's sector, rank, and RS
• Dual classification: ETF Holdings + TradingView (mismatch detection)

6️⃣ Macro Cross-Asset Flow
• Tracks 6 macro assets for broader market context
• Interprets flows: Risk-Off Flow, Risk-On Flow, Flight to Safety
• Equity outflow warnings when safe havens beat SPX significantly

7️⃣ Educational Tooltips
• Hover over ANY cell for detailed explanations
• Dynamic tooltips show live data + educational context
• Learn what drives each signal while you trade


📖 HOW TO READ THE DASHBOARD

Sector Panel:
• Green background = Outperforming SPX (positive RS)
• Red background = Underperforming SPX (negative RS)
• Green text = Positive absolute return
• Red text = Negative absolute return
• Δ column shows rank changes (⚠️ = significant move)

Interpretation Panel:
• ROTATION → Describes current sector movement pattern
• REGIME → Current market environment classification
• ALERT → Anomalies detected or "All Clear" status
• CONFIDENCE → Signal reliability score with breakdown

Macro Panel:
• Signal column: Strong > Bid > Neutral > Offered > Weak
• FLOW row: Summary of cross-asset money movement


⚙️ SETTINGS & RECOMMENDATIONS

PRIMARY TIMEFRAME (days) - Default: 20
Lookback period for RS calculation.
• 5-10 days: Day/swing traders - responsive but noisier
• 20 days: Most traders - good balance of signal vs noise ⭐
• 50 days: Position traders - smooth, confirms established trends
• 100+ days: Investors - major regime shifts only
Tip: Match to your typical holding period.

TREND TIMEFRAME (days) - Default: 5
Shorter lookback for momentum arrows (↑↑ ↑ → ↓ ↓↓).
• 3 days: Aggressive - more sensitive, more arrow changes
• 5 days: Most traders - catches momentum shifts without whipsaws ⭐
• 10 days: Conservative - smoother, fewer false reversals
Tip: Keep at 1/4 to 1/5 of Primary Timeframe.

ALERT THRESHOLD (ranks) - Default: 3
Minimum rank change to trigger ⚠️ anomaly alert.
• 2 ranks: Active traders - more alerts, catches smaller rotations
• 3 ranks: Most traders - significant moves only (e.g., #8→#5) ⭐
• 4-5 ranks: Swing/position - major disruptions only, high conviction
Tip: Lower = more alerts, Higher = fewer but stronger signals.

RECOMMENDED COMBINATIONS BY TRADING STYLE:
• Day Trading: Primary 10, Trend 3, Alert 2
• Swing Trading: Primary 20, Trend 5, Alert 3
• Position Trading: Primary 50, Trend 10, Alert 4
• Long-term Investing: Primary 100, Trend 20, Alert 5

OTHER SETTINGS:
• 44+ color and opacity controls for full customization
• Dark/Light theme support
• Compact view (Top 3 + Bottom 3) or Full view (all 11)
• Show/hide interpretation panel


🚨 BUILT-IN ALERTS

• Sector rotation changes (Cyclical ↔ Defensive)
• Regime changes (Risk-On ↔ Risk-Off ↔ Tech-Led)
• Large rank movements (configurable threshold)
• Equity outflow detection
• Safe haven bid alerts
• Global risk-on signals


💡 TRADING APPLICATIONS

For Stock Traders:
• See if your stock's sector is leading or lagging
• Avoid fighting the sector trend
• Find stocks in leading sectors for momentum plays

For Sector Rotators:
• Identify rotation early with rank change alerts
• Confirm regime with confidence scoring
• Spot anomalies that may signal turning points

For Portfolio Managers:
• Monitor risk-on/risk-off positioning
• Track cross-asset correlations
• Get early warning of defensive rotations

For Macro Traders:
• Cross-reference sector rotation with macro flows
• Identify flight-to-safety episodes
• Track inflation hedge positioning


📝 TECHNICAL NOTES

• Data Source: TradingView sector data + custom ETF holdings database
• ETF Holdings: 500+ tickers mapped to sector ETFs (manually maintained)
• Rebalancing: SPDR ETFs rebalance on 3rd Friday of Mar/Jun/Sep/Dec
• Best Timeframe: Daily recommended, works on all timeframes
• Performance: Optimized for minimal lag despite tracking 17 assets
• Pine Script: Version 6

⚠️ DATA UPDATE SCHEDULE:
The ETF holdings database is manually updated by the creator following each quarterly rebalance. Updates are typically completed within 1-2 weeks after the official rebalance date. During this period, some ticker classifications may be outdated. The indicator will fall back to TradingView's sector classification for any tickers not found in the database.


⚠️ DISCLAIMER

This indicator is currently in BETA. Features may change, and bugs may exist.

This indicator is for educational and informational purposes only. It does not constitute financial advice. Always do your own research and consider your risk tolerance before making trading decisions. Past performance does not guarantee future results.

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.