OPEN-SOURCE SCRIPT
LONG MARKET CONTROL SPY / VIX / DXY

Here's an English description you can use for the indicator (e.g., for the TradingView publishing page or as a header comment):
---
**LONG MARKET CONTROL – SPY / VIX / DXY**
A composite U.S. market regime indicator built for long-only trading decisions. It scores overall market conditions from 0–100 by combining SPY trend/structure/momentum, VIX fear-level and rate-of-change, and DXY dollar-direction dynamics, then applies a correlation adjustment based on how the three interact (e.g., full risk-on, classic risk-off, or the more dangerous "U.S. asset stress" pattern where stocks fall, VIX rises, and the dollar falls at the same time — money leaving U.S. assets without fleeing to the dollar as a safe haven).
**What it does:**
- Calculates a 0–100 Market Score (SPY worth up to 50 pts, VIX up to 30, DXY up to 20, plus a correlation adjustment of −10 to +5) and classifies the market into five color-coded regimes: Strong Risk-On, Selective Long, Caution, Risk-Off, and Market Veto — each with a suggested maximum position size.
- Detects a **Market Veto** state (hard stop on new longs) using six independent trigger conditions (breakdown below the 150-day MA, VIX spike above 30, high-volume breakdown of the 20-day low, etc.), shown with a red background and a dedicated alert.
- Tracks a separate **Recovery Score** (0–20) after panic/veto conditions to flag early recovery, confirmed recovery, and prevents the score from jumping straight from red to dark green in a single day.
- Measures **market breadth** (RSP, IWM, QQQ vs. SPY) to flag narrow, mega-cap-driven rallies.
- Ranks all 11 S&P sector ETFs (XLK, XLC, XLY, XLF, XLI, XLE, XLB, XLV, XLP, XLU, XLRE) by relative strength vs. SPY and surfaces the top 3 / bottom 3 leaders.
- A built-in **"Where To Look"** engine translates the current SPY/VIX/DXY combination into a plain-language suggestion of which asset classes or sectors typically show relative strength in that regime (e.g., gold/silver/miners during "U.S. asset stress," defensives during classic risk-off, tech/growth during full risk-on).
- On-chart dashboard table, background/label state markers, and 17 built-in alert conditions with fully dynamic alert text (state, score, prices, top sectors, recommended position size).
All core calculations run on **daily data** via `request.security()` regardless of the chart's timeframe, with an option to use only confirmed (closed) daily bars to avoid repainting.
*For educational and analytical purposes only — not financial advice. All symbols and thresholds are user-configurable via the Inputs panel.*
**LONG MARKET CONTROL – SPY / VIX / DXY**
אינדיקטור למצב השוק האמריקאי, מיועד לקבלת החלטות מסחר בלונג בלבד. הוא נותן ציון שוק בין 0 ל־100 על סמך שילוב של מגמת SPY (מבנה מחיר ומומנטום), רמת הפחד ב־VIX וקצב השינוי שלו, וכיוון הדולר לפי DXY — ולאחר מכן מפעיל התאמת קורלציה לפי האופן שבו שלושת הגורמים משפיעים זה על זה (למשל Risk-On מלא, Risk-Off קלאסי, או המצב המסוכן ביותר — "U.S. Asset Stress" — שבו מניות יורדות, VIX עולה והדולר יורד בו־זמנית, כלומר כסף בורח מנכסים אמריקאיים בלי לברוח לדולר כמקלט).
**מה האינדיקטור עושה:**
- מחשב ציון שוק בין 0 ל־100 (SPY עד 50 נקודות, VIX עד 30, DXY עד 20, בתוספת התאמת קורלציה בין מינוס 10 לפלוס 5), ומסווג את השוק לחמישה מצבים צבעוניים: Strong Risk-On, Selective Long, Caution, Risk-Off ו־Market Veto — כל אחד עם המלצת גודל פוזיציה מקסימלי.
- מזהה מצב **Market Veto** (עצירה מוחלטת לכניסות לונג חדשות) לפי שישה תנאים עצמאיים (שבירת MA150, קפיצת VIX מעל 30, שבירת שפל 20 יום בווליום גבוה ועוד), עם רקע אדום ו־Alert נפרד.
- עוקב אחרי **Recovery Score** נפרד (0–20) לאחר מצבי פאניקה/Veto, מסמן התאוששות ראשונית והתאוששות מאושרת, ומונע קפיצה ישירה מאדום לירוק כהה תוך יום אחד.
- מודד **רוחב שוק** (RSP, IWM, QQQ מול SPY) כדי לזהות עליות "צרות" המבוססות על מעט מניות ענק.
- מדרג את 11 סקטורי ה־S&P (XLK, XLC, XLY, XLF, XLI, XLE, XLB, XLV, XLP, XLU, XLRE) לפי חוזקה יחסית מול SPY, ומציג את 3 המובילים ו־3 החלשים.
- מנוע **"Where To Look"** מובנה שמתרגם את שילוב ה־SPY/VIX/DXY הנוכחי להמלצה בשפה פשוטה על אילו נכסים או סקטורים נוטים להראות חוזקה יחסית באותו מצב (למשל זהב/כסף/כורים ב־"U.S. Asset Stress", דפנסיביים ב־Risk-Off קלאסי, טכנולוגיה וצמיחה ב־Risk-On מלא).
- טבלת דשבורד על הגרף, סימוני רקע ותוויות מעבר מצב, ו־17 תנאי Alert מובנים עם טקסט דינמי מלא (מצב, ציון, מחירים, סקטורים מובילים, גודל פוזיציה מומלץ).
כל החישובים המרכזיים רצים על **נתוני Daily** דרך `request.security()` ללא תלות בטיימפריים של הגרף, עם אפשרות להשתמש רק בנרות יומיים סגורים כדי למנוע Repainting.
*למטרות לימוד וניתוח בלבד — אין לראות בכך ייעוץ השקעות. כל הסמלים והספים ניתנים להתאמה אישית דרך פאנל ה־Inputs.*
---
**LONG MARKET CONTROL – SPY / VIX / DXY**
A composite U.S. market regime indicator built for long-only trading decisions. It scores overall market conditions from 0–100 by combining SPY trend/structure/momentum, VIX fear-level and rate-of-change, and DXY dollar-direction dynamics, then applies a correlation adjustment based on how the three interact (e.g., full risk-on, classic risk-off, or the more dangerous "U.S. asset stress" pattern where stocks fall, VIX rises, and the dollar falls at the same time — money leaving U.S. assets without fleeing to the dollar as a safe haven).
**What it does:**
- Calculates a 0–100 Market Score (SPY worth up to 50 pts, VIX up to 30, DXY up to 20, plus a correlation adjustment of −10 to +5) and classifies the market into five color-coded regimes: Strong Risk-On, Selective Long, Caution, Risk-Off, and Market Veto — each with a suggested maximum position size.
- Detects a **Market Veto** state (hard stop on new longs) using six independent trigger conditions (breakdown below the 150-day MA, VIX spike above 30, high-volume breakdown of the 20-day low, etc.), shown with a red background and a dedicated alert.
- Tracks a separate **Recovery Score** (0–20) after panic/veto conditions to flag early recovery, confirmed recovery, and prevents the score from jumping straight from red to dark green in a single day.
- Measures **market breadth** (RSP, IWM, QQQ vs. SPY) to flag narrow, mega-cap-driven rallies.
- Ranks all 11 S&P sector ETFs (XLK, XLC, XLY, XLF, XLI, XLE, XLB, XLV, XLP, XLU, XLRE) by relative strength vs. SPY and surfaces the top 3 / bottom 3 leaders.
- A built-in **"Where To Look"** engine translates the current SPY/VIX/DXY combination into a plain-language suggestion of which asset classes or sectors typically show relative strength in that regime (e.g., gold/silver/miners during "U.S. asset stress," defensives during classic risk-off, tech/growth during full risk-on).
- On-chart dashboard table, background/label state markers, and 17 built-in alert conditions with fully dynamic alert text (state, score, prices, top sectors, recommended position size).
All core calculations run on **daily data** via `request.security()` regardless of the chart's timeframe, with an option to use only confirmed (closed) daily bars to avoid repainting.
*For educational and analytical purposes only — not financial advice. All symbols and thresholds are user-configurable via the Inputs panel.*
**LONG MARKET CONTROL – SPY / VIX / DXY**
אינדיקטור למצב השוק האמריקאי, מיועד לקבלת החלטות מסחר בלונג בלבד. הוא נותן ציון שוק בין 0 ל־100 על סמך שילוב של מגמת SPY (מבנה מחיר ומומנטום), רמת הפחד ב־VIX וקצב השינוי שלו, וכיוון הדולר לפי DXY — ולאחר מכן מפעיל התאמת קורלציה לפי האופן שבו שלושת הגורמים משפיעים זה על זה (למשל Risk-On מלא, Risk-Off קלאסי, או המצב המסוכן ביותר — "U.S. Asset Stress" — שבו מניות יורדות, VIX עולה והדולר יורד בו־זמנית, כלומר כסף בורח מנכסים אמריקאיים בלי לברוח לדולר כמקלט).
**מה האינדיקטור עושה:**
- מחשב ציון שוק בין 0 ל־100 (SPY עד 50 נקודות, VIX עד 30, DXY עד 20, בתוספת התאמת קורלציה בין מינוס 10 לפלוס 5), ומסווג את השוק לחמישה מצבים צבעוניים: Strong Risk-On, Selective Long, Caution, Risk-Off ו־Market Veto — כל אחד עם המלצת גודל פוזיציה מקסימלי.
- מזהה מצב **Market Veto** (עצירה מוחלטת לכניסות לונג חדשות) לפי שישה תנאים עצמאיים (שבירת MA150, קפיצת VIX מעל 30, שבירת שפל 20 יום בווליום גבוה ועוד), עם רקע אדום ו־Alert נפרד.
- עוקב אחרי **Recovery Score** נפרד (0–20) לאחר מצבי פאניקה/Veto, מסמן התאוששות ראשונית והתאוששות מאושרת, ומונע קפיצה ישירה מאדום לירוק כהה תוך יום אחד.
- מודד **רוחב שוק** (RSP, IWM, QQQ מול SPY) כדי לזהות עליות "צרות" המבוססות על מעט מניות ענק.
- מדרג את 11 סקטורי ה־S&P (XLK, XLC, XLY, XLF, XLI, XLE, XLB, XLV, XLP, XLU, XLRE) לפי חוזקה יחסית מול SPY, ומציג את 3 המובילים ו־3 החלשים.
- מנוע **"Where To Look"** מובנה שמתרגם את שילוב ה־SPY/VIX/DXY הנוכחי להמלצה בשפה פשוטה על אילו נכסים או סקטורים נוטים להראות חוזקה יחסית באותו מצב (למשל זהב/כסף/כורים ב־"U.S. Asset Stress", דפנסיביים ב־Risk-Off קלאסי, טכנולוגיה וצמיחה ב־Risk-On מלא).
- טבלת דשבורד על הגרף, סימוני רקע ותוויות מעבר מצב, ו־17 תנאי Alert מובנים עם טקסט דינמי מלא (מצב, ציון, מחירים, סקטורים מובילים, גודל פוזיציה מומלץ).
כל החישובים המרכזיים רצים על **נתוני Daily** דרך `request.security()` ללא תלות בטיימפריים של הגרף, עם אפשרות להשתמש רק בנרות יומיים סגורים כדי למנוע Repainting.
*למטרות לימוד וניתוח בלבד — אין לראות בכך ייעוץ השקעות. כל הסמלים והספים ניתנים להתאמה אישית דרך פאנל ה־Inputs.*
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.