OPEN-SOURCE SCRIPT
Zaktualizowano Regime Switch 100/200 SMA

What it does
Daily, close-only trend regime for any symbol using the 100-day (momentum) and 200-day (regime) SMAs. Classifies the tape into GREEN / YELLOW / RED and stays stable intraday.
How it works (rules)
Inputs
Visuals & alerts
How to use (workflow)
Notes
Change log
Disclosure
Educational use only. Not investment advice.
Daily, close-only trend regime for any symbol using the 100-day (momentum) and 200-day (regime) SMAs. Classifies the tape into GREEN / YELLOW / RED and stays stable intraday.
How it works (rules)
- GREEN = Close > 100D and 100D > 200D -> full risk-on.
- YELLOW = Close > 200D and 100D <= 200D -> light risk-on / repair.
- RED = Close < 200D -> risk-off.
- State changes require N = 2 daily closes (configurable).
- Optional +/- band % around 200D to reduce whipsaws.
- Always computes on daily data (independent of chart timeframe).
Inputs
- Use chart symbol? (else pick a fixed symbol)
- Fast SMA length (default 100)
- Slow SMA length (default 200)
- Daily closes to confirm (default 2)
- Buffer band % around 200D (default 0)
- Toggles: state-change markers, status panel, SMA labels
Visuals & alerts
- Background: GREEN / YELLOW / RED by state
- Lines: SMA100 (yellow) and SMA200 (orange)
- Markers on state flips; three alertconditions fire on GREEN / YELLOW / RED changes
How to use (workflow)
- View with 1D candles, ~1Y range.
- Decide at the daily close; execute next day’s open.
- Example sizing when signaling on QQQ and expressing with TQQQ:
- GREEN -> sleeve 10–15% (cap 20–25%); trim if sleeve > target x 1.25.
- YELLOW -> sleeve 5–8% (half risk).
- RED -> 0%; sit in cash until GREEN or YELLOW returns. - No margin/loans layered on leveraged ETFs.
Notes
- Works with regular candles; dividend-adjustment settings can nudge SMA values.
- For faster but noisier behavior, shorten to 150/100D or set Confirm=1.
Change log
- v1.0: Initial release (daily, 3-state, follows chart symbol, alerts, panel).
Disclosure
Educational use only. Not investment advice.
Informacje o Wersji
TQQQ Regime Throttle (100–200 SMA, Vol Aware)What it does
A simple, robust regime map using QQQ’s 100/200-day SMAs, upgraded with:
- Volatility gate: only “enables” TQQQ when realized vol and ATR% are tame.
- Dynamic band & confirmations: adds a small buffer around the 200D and raises confirmations as vol rises to reduce whipsaws.
- TrendScore → suggested sleeve: converts trend quality into a suggested position size, capped to your risk budget.
- Expression hint: tells you when to use TQQQ vs QQQ vs Cash.
States (computed on QQQ daily; act next day’s open)
- GREEN – Close > 100D AND 100D > 200D → Risk ON.
- YELLOW – Close > 200D AND 100D ≤ 200D → Light risk.
- RED – Close < 200D → Risk OFF (cash).
Panel fields (what you’ll see)
- RISK: current regime (GREEN / YELLOW / RED).
- Close vs 200D and 100D ? 200D: structure of the trend.
- Confirm | Band: required closes to flip state and the dynamic ±% buffer on the 200D.
- AnnVol | ATR%: realized volatility (annualized) and ATR as % of price.
- TrendScore (0–1): higher = stronger, cleaner trend.
- Express: TQQQ / QQQ / Cash — based on regime + vol gates + TrendScore.
- Suggested sleeve: position size guidance for your TQQQ sleeve after vol/trend scaling and your cap.
How to use (discipline)
- Decide at the daily close; execute at the next day’s open.
- If Express: TQQQ → allocate up to Suggested sleeve (respect your cap).
- If Express: QQQ → stay unlevered (trend OK but vol too hot / quality marginal).
- If RED → flat/cash.
- Rebalance trims: if sleeve value > target × 1.25, cut back to target.
Inputs (tunable)
- Fast/Slow SMA: defaults 100/200.
- ConfirmBars: base confirmations (dynamic add-ons with vol).
- Vol lookback, ATR length.
- Max AnnVol for TQQQ and Max ATR%: tighten to be more conservative.
- Base sleeves & cap: set your GREEN/YELLOW targets and overall cap.
- Dynamic band & confirm multipliers: increase slightly to reduce flip-flops in choppy markets.
Why it’s different from a plain MA filter
- Leverage is conditional: only when drift ≫ noise.
- Whipsaw control: vol-aware banding and confirmations near the 200D where decay is most damaging.
- Sizing is systematic: stronger/cleaner trends earn more sleeve (capped).
Notes & best practices
- Signal is based on QQQ daily regardless of chart timeframe (via security() calls).
- Updates after the daily bar closes. Intra-day moves do not flip state.
- This is an indicator, not a strategy; Suggested sleeve is guidance for discretionary risk.
- You can toggle to use your chart symbol instead of QQQ if you prefer.
Alerts
- Regime: GREEN / YELLOW / RED on state changes.
- Express with TQQQ when trend is strong and vol is acceptable.
- Do NOT use TQQQ when vol is too high or trend weakens (prefer QQQ/cash).
Changelog
- v1.0 – Initial public release: vol gate, dynamic band/confirm, TrendScore sizing, expression hint, hardened symbol handling.
Disclaimer
This is educational material, not investment advice. Leveraged ETFs amplify gains and losses. Backtest your workflow and size prudently.
Informacje o Wersji
Overview Rule-based risk expression for QQQ/TQQQ with explicit action prompts. The panel translates a 100/200-day SMA regime on QQQ into what to hold and how big to size, so decisions are consistent.TL;DR This indicator pairs a 100/200-day SMA regime on QQQ with a volatility gate and a TrendScore so the panel tells you how to express risk: Express: TQQQ (use leverage and stay in TQQQ while this hint persists, subject to trims), Express: QQQ (stay unlevered), or Express: Cash (flat). It also suggests a sleeve size when enabled (e.g., 8–10% in GREEN if you set that band). What’s different vs a plain MA system - Express hint: converts regime into an action—TQQQ vs QQQ vs Cash. “Express: TQQQ” means be long TQQQ until the hint changes per rules (or your trims hit).
- Volatility gate: AnnVol and ATR% thresholds must be met to enable TQQQ; if not, you remain in QQQ or Cash even if GREEN.
- TrendScore → size: maps trend quality to a suggested sleeve %, capped to your risk budget.
- Dynamic guardrails: optional buffer around the 200D and extra confirmations at higher vol to curb whipsaws.
- GREEN = Close > 100D and 100D > 200D.
- YELLOW = Close > 200D and 100D ≤ 200D.
- RED = Close < 200D.
- RISK: GREEN/YELLOW/RED per QQQ daily (updates on daily closes).
- Confirm | Band: required closes to change color; small ±% buffer on the 200D when vol rises.
- AnnVol | ATR%: realized vol and ATR% used by the gate.
- TrendScore (0–1): higher = stronger, cleaner trend.
- Express: what to hold—TQQQ if risk-on and vol tame; QQQ if risk-on but vol hot or trend marginal; Cash if risk-off.
- Suggested sleeve: size guidance when enabled (TrendScore × vol scaling, capped).
- Decide at the daily close; execute at the next open.
- If GREEN + Express: TQQQ → allocate up to Suggested sleeve (respect your cap).
- If GREEN + Express: QQQ → stay unlevered until vol cools or TrendScore improves.
- If YELLOW → light risk; follow the panel’s suggestion.
- If RED → flat/cash.
- Trim rule: if sleeve value > target × 1.25, rebalance back to target.
- MA lengths (100/200) and confirmations.
- Vol lookback, ATR length, Max AnnVol, Max ATR% (stricter = less TQQQ).
- Base sleeves for GREEN/YELLOW and overall cap (e.g., GREEN 8–10%).
- Dynamic band/confirm multipliers (raise to reduce flip-flops).
- Signal source: QQQ by default; can follow your chart symbol.
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.