OPEN-SOURCE SCRIPT
SPAZZ Daily/Weekly

# SPAZZ Daily/Weekly (SFI)
**A mean-reversion entry filter that combines RSI z-score zero-crossings with Bollinger Band touch-and-reclaim — triggering only when momentum normalization and price envelope reversion agree on the same bar.**
---
## What It Does
SPAZZ SFI computes a z-score of RSI(14) by subtracting its 14-period SMA and dividing by its 14-period standard deviation, then gates entries on the z-score crossing zero coinciding with price crossing back inside a Bollinger Band (20-period, 1.76σ default). The dual-gate design filters out standalone BB touches that lack momentum confirmation and standalone RSI recoveries that haven't reached envelope extremes. Signals only fire when both conditions align on the same bar — a conjunction filter that materially reduces false positives relative to either component alone.
---
## Theoretical Foundations
- **Bollinger Bands (Bollinger, 1983)** — Price envelope defined as SMA(20) ± kσ. The non-standard default multiplier of 1.76σ (vs. the typical 2.0σ) widens the signal zone, capturing reversion setups before price reaches full 2σ extension — a deliberate sensitivity tradeoff
- **RSI z-score normalization** — Raw RSI is bounded [0, 100] and non-stationary across regimes. Z-scoring against its own rolling distribution converts it to a zero-centered, approximately unit-variance series where zero-crossings represent transitions from below-mean to above-mean momentum (and vice versa), independent of the prevailing RSI level
- **Conjunction filtering** — Requiring two independent conditions to fire simultaneously on the same bar exploits the low joint probability of co-occurrence under noise. If each condition fires independently with probability *p*, the conjunction fires with probability ≈ *p²* under independence — geometrically reducing false signal rates
---
## Signals
**Bullish (BUY):**
- RSI z-score crosses above zero (momentum recovering from below-average) **AND** price crosses above the lower Bollinger Band (reclaiming the envelope from below)
- Interpretation: price was extended to the downside and is now showing simultaneous mean-reversion in both price level and momentum — a high-probability long entry zone
**Bearish (SELL):**
- RSI z-score crosses below zero (momentum deteriorating from above-average) **AND** price crosses below the upper Bollinger Band (failing to hold the upper envelope)
- Interpretation: price was extended to the upside and is now losing momentum while falling back inside the band — a high-probability short entry or exit zone
**No Signal:**
- Z-score crosses zero but price is mid-band → momentum shift without envelope extremity
- Price touches a band but z-score doesn't cross zero → envelope touch without confirmed momentum reversal
---
## Overlay Fields
| Plot | Description |
|------|-------------|
| **Up Triangle** | Green triangle below bar on BUY signal |
| **Down Triangle** | Red triangle above bar on SELL signal |
| **BUY Label** | Optional text label at low of signal bar |
| **SELL Label** | Optional text label at high of signal bar |
No Bollinger Band lines are plotted (overlay remains clean). The BB computation is internal to the signal logic only.
---
## Key Inputs
| Input | Default | Guidance |
|-------|---------|----------|
| **BB Multiplier** | 1.76 | Controls band width. Lower values (1.5–1.7) increase signal frequency by catching shallower pullbacks. Higher values (2.0–2.5) require deeper extension before triggering — fewer but more extreme signals. The 1.76 default sits between standard (2.0) and aggressive (1.5). |
| **Show Labels** | On | Toggle BUY/SELL text labels. Disable for cleaner charts when using alerts instead of visual scanning. |
| **Timeframe** | D | Selector for Daily or Weekly. **Note:** This input is declared but not wired to `request.security()` in the current version — the indicator runs on the chart's native timeframe regardless of this setting. |
---
## Data Sources & request.security() Budget
**Total request.security() usage: 0 of 40.** All computations use the chart's native timeframe and symbol. No external data calls.
---
## Alerts
| Alert | Trigger | Frequency |
|-------|---------|-----------|
| **BUY** | RSI z-score crosses above 0 AND close crosses above lower BB | Once per bar close |
| **SELL** | RSI z-score crosses below 0 AND close crosses below upper BB | Once per bar close |
Both alerts use `alertcondition()` — static presets configured in TradingView's alert dialog. No dynamic `alert()` calls.
---
## Important Notes
- **Anti-repainting:** All computations use `close`, `ta.crossover()`, and `ta.crossunder()` on confirmed bar data. No `request.security()` calls, no lookahead. Signals are fixed once the bar closes.
- **Timeframe input is cosmetic:** The `input.timeframe()` selector is present in the UI but not connected to any MTF logic. The indicator always runs on the chart's native timeframe. To analyze Daily signals on a Weekly chart (or vice versa), change the chart timeframe directly.
- **BB multiplier sensitivity:** At the default 1.76σ, bands are ~12% tighter than standard 2.0σ Bollinger Bands. This means signals fire more frequently but at less extreme price levels. If you observe excessive false signals, increase toward 2.0–2.2.
- **RSI z-score warmup:** The z-score requires 2× RSI_LENGTH bars (28 bars) to stabilize — 14 for the RSI series itself and 14 for its rolling mean and standard deviation. Signals within the first ~30 bars of chart history are unreliable.
- **Conjunction is strict:** Because both conditions must co-occur on the exact same bar, signal frequency is low. On daily BTC charts, expect roughly 2–6 signals per month depending on regime. This is by design — it is an entry filter, not a continuous scoring system.
**A mean-reversion entry filter that combines RSI z-score zero-crossings with Bollinger Band touch-and-reclaim — triggering only when momentum normalization and price envelope reversion agree on the same bar.**
---
## What It Does
SPAZZ SFI computes a z-score of RSI(14) by subtracting its 14-period SMA and dividing by its 14-period standard deviation, then gates entries on the z-score crossing zero coinciding with price crossing back inside a Bollinger Band (20-period, 1.76σ default). The dual-gate design filters out standalone BB touches that lack momentum confirmation and standalone RSI recoveries that haven't reached envelope extremes. Signals only fire when both conditions align on the same bar — a conjunction filter that materially reduces false positives relative to either component alone.
---
## Theoretical Foundations
- **Bollinger Bands (Bollinger, 1983)** — Price envelope defined as SMA(20) ± kσ. The non-standard default multiplier of 1.76σ (vs. the typical 2.0σ) widens the signal zone, capturing reversion setups before price reaches full 2σ extension — a deliberate sensitivity tradeoff
- **RSI z-score normalization** — Raw RSI is bounded [0, 100] and non-stationary across regimes. Z-scoring against its own rolling distribution converts it to a zero-centered, approximately unit-variance series where zero-crossings represent transitions from below-mean to above-mean momentum (and vice versa), independent of the prevailing RSI level
- **Conjunction filtering** — Requiring two independent conditions to fire simultaneously on the same bar exploits the low joint probability of co-occurrence under noise. If each condition fires independently with probability *p*, the conjunction fires with probability ≈ *p²* under independence — geometrically reducing false signal rates
---
## Signals
**Bullish (BUY):**
- RSI z-score crosses above zero (momentum recovering from below-average) **AND** price crosses above the lower Bollinger Band (reclaiming the envelope from below)
- Interpretation: price was extended to the downside and is now showing simultaneous mean-reversion in both price level and momentum — a high-probability long entry zone
**Bearish (SELL):**
- RSI z-score crosses below zero (momentum deteriorating from above-average) **AND** price crosses below the upper Bollinger Band (failing to hold the upper envelope)
- Interpretation: price was extended to the upside and is now losing momentum while falling back inside the band — a high-probability short entry or exit zone
**No Signal:**
- Z-score crosses zero but price is mid-band → momentum shift without envelope extremity
- Price touches a band but z-score doesn't cross zero → envelope touch without confirmed momentum reversal
---
## Overlay Fields
| Plot | Description |
|------|-------------|
| **Up Triangle** | Green triangle below bar on BUY signal |
| **Down Triangle** | Red triangle above bar on SELL signal |
| **BUY Label** | Optional text label at low of signal bar |
| **SELL Label** | Optional text label at high of signal bar |
No Bollinger Band lines are plotted (overlay remains clean). The BB computation is internal to the signal logic only.
---
## Key Inputs
| Input | Default | Guidance |
|-------|---------|----------|
| **BB Multiplier** | 1.76 | Controls band width. Lower values (1.5–1.7) increase signal frequency by catching shallower pullbacks. Higher values (2.0–2.5) require deeper extension before triggering — fewer but more extreme signals. The 1.76 default sits between standard (2.0) and aggressive (1.5). |
| **Show Labels** | On | Toggle BUY/SELL text labels. Disable for cleaner charts when using alerts instead of visual scanning. |
| **Timeframe** | D | Selector for Daily or Weekly. **Note:** This input is declared but not wired to `request.security()` in the current version — the indicator runs on the chart's native timeframe regardless of this setting. |
---
## Data Sources & request.security() Budget
**Total request.security() usage: 0 of 40.** All computations use the chart's native timeframe and symbol. No external data calls.
---
## Alerts
| Alert | Trigger | Frequency |
|-------|---------|-----------|
| **BUY** | RSI z-score crosses above 0 AND close crosses above lower BB | Once per bar close |
| **SELL** | RSI z-score crosses below 0 AND close crosses below upper BB | Once per bar close |
Both alerts use `alertcondition()` — static presets configured in TradingView's alert dialog. No dynamic `alert()` calls.
---
## Important Notes
- **Anti-repainting:** All computations use `close`, `ta.crossover()`, and `ta.crossunder()` on confirmed bar data. No `request.security()` calls, no lookahead. Signals are fixed once the bar closes.
- **Timeframe input is cosmetic:** The `input.timeframe()` selector is present in the UI but not connected to any MTF logic. The indicator always runs on the chart's native timeframe. To analyze Daily signals on a Weekly chart (or vice versa), change the chart timeframe directly.
- **BB multiplier sensitivity:** At the default 1.76σ, bands are ~12% tighter than standard 2.0σ Bollinger Bands. This means signals fire more frequently but at less extreme price levels. If you observe excessive false signals, increase toward 2.0–2.2.
- **RSI z-score warmup:** The z-score requires 2× RSI_LENGTH bars (28 bars) to stabilize — 14 for the RSI series itself and 14 for its rolling mean and standard deviation. Signals within the first ~30 bars of chart history are unreliable.
- **Conjunction is strict:** Because both conditions must co-occur on the exact same bar, signal frequency is low. On daily BTC charts, expect roughly 2–6 signals per month depending on regime. This is by design — it is an entry filter, not a continuous scoring system.
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.