OPEN-SOURCE SCRIPT
Rainbow MA Width

█ OVERVIEW
Rainbow MA Width is a companion indicator for Rainbow MA Cloud. It displays ribbon width as a normalized Z-Score, allowing traders to visualize trend momentum expansion and contraction relative to recent history.
█ CONCEPTS
Z-Score Normalization:
Rather than displaying raw width values (which vary by asset and timeframe),
this indicator normalizes the ribbon width using Z-Score calculation:
Z-Score = (Current Width - Average Width) / Standard Deviation
Z-Score Interpretation:
• 0 = Average width (mean)
• +1 to +2 = Expanding (above average, strong trend)
• -1 to -2 = Contracting (below average, weakening trend)
• Beyond ±2 = Extreme (statistical outlier, potential reversal)
Width Calculation Modes:
• Outer — Distance between fastest and slowest MA: |MA1 - MA8|
• Average Gap — Mean of all adjacent MA gaps
• Total Gap — Sum of all adjacent MA gaps
█ FEATURES
1 — Width Mode Selection
Three methods to calculate ribbon width.
"Outer" recommended for aligned trends.
2 — Z-Score Period
Configurable lookback for mean and standard deviation.
Default 20 bars; increase for smoother, less reactive readings.
3 — Zone Fill Coloring
Cyan fill when expanding (Z > 0).
Orange fill when contracting (Z < 0).
Yellow fill for extreme values (|Z| > 2) as warning.
4 — Alignment Background
Green background during bullish alignment.
Red background during bearish alignment.
Synced with Rainbow MA Cloud for consistency.
5 — Reference Lines
Horizontal lines at 0 (mean), ±1σ, and ±2σ levels.
Provides clear visual boundaries for interpretation.
6 — Raw Width Display
Optional secondary line showing original width percentage.
Useful for comparing normalized vs absolute values.
█ HOW TO USE
Trend Confirmation:
• Z-Score rising above 0 confirms trend acceleration
• Z-Score staying above +1 indicates sustained strong momentum
• Use alongside alignment background for confluence
Reversal Warning:
• Z-Score exceeding +2 suggests overextension (yellow warning zone)
• Z-Score dropping below -2 indicates extreme contraction
• Extreme readings often precede trend reversals or consolidation
Entry Timing:
• Enter trends when Z-Score crosses above 0 (expansion beginning)
• Avoid entries when Z-Score is at extreme highs (potential exhaustion)
• Consider exits when Z-Score peaks and begins declining
█ LIMITATIONS
• Z-Score is relative to lookback period; different periods give different readings
• Extreme zones (±2) are statistical guides, not guarantees
• Best used in conjunction with Rainbow MA Cloud for full context
█ ALERTS
Four built-in alert conditions:
• Z-Score crosses above/below zero
• Z-Score enters extreme high/low zones (±2)
Rainbow MA Width is a companion indicator for Rainbow MA Cloud. It displays ribbon width as a normalized Z-Score, allowing traders to visualize trend momentum expansion and contraction relative to recent history.
█ CONCEPTS
Z-Score Normalization:
Rather than displaying raw width values (which vary by asset and timeframe),
this indicator normalizes the ribbon width using Z-Score calculation:
Z-Score = (Current Width - Average Width) / Standard Deviation
Z-Score Interpretation:
• 0 = Average width (mean)
• +1 to +2 = Expanding (above average, strong trend)
• -1 to -2 = Contracting (below average, weakening trend)
• Beyond ±2 = Extreme (statistical outlier, potential reversal)
Width Calculation Modes:
• Outer — Distance between fastest and slowest MA: |MA1 - MA8|
• Average Gap — Mean of all adjacent MA gaps
• Total Gap — Sum of all adjacent MA gaps
█ FEATURES
1 — Width Mode Selection
Three methods to calculate ribbon width.
"Outer" recommended for aligned trends.
2 — Z-Score Period
Configurable lookback for mean and standard deviation.
Default 20 bars; increase for smoother, less reactive readings.
3 — Zone Fill Coloring
Cyan fill when expanding (Z > 0).
Orange fill when contracting (Z < 0).
Yellow fill for extreme values (|Z| > 2) as warning.
4 — Alignment Background
Green background during bullish alignment.
Red background during bearish alignment.
Synced with Rainbow MA Cloud for consistency.
5 — Reference Lines
Horizontal lines at 0 (mean), ±1σ, and ±2σ levels.
Provides clear visual boundaries for interpretation.
6 — Raw Width Display
Optional secondary line showing original width percentage.
Useful for comparing normalized vs absolute values.
█ HOW TO USE
Trend Confirmation:
• Z-Score rising above 0 confirms trend acceleration
• Z-Score staying above +1 indicates sustained strong momentum
• Use alongside alignment background for confluence
Reversal Warning:
• Z-Score exceeding +2 suggests overextension (yellow warning zone)
• Z-Score dropping below -2 indicates extreme contraction
• Extreme readings often precede trend reversals or consolidation
Entry Timing:
• Enter trends when Z-Score crosses above 0 (expansion beginning)
• Avoid entries when Z-Score is at extreme highs (potential exhaustion)
• Consider exits when Z-Score peaks and begins declining
█ LIMITATIONS
• Z-Score is relative to lookback period; different periods give different readings
• Extreme zones (±2) are statistical guides, not guarantees
• Best used in conjunction with Rainbow MA Cloud for full context
█ ALERTS
Four built-in alert conditions:
• Z-Score crosses above/below zero
• Z-Score enters extreme high/low zones (±2)
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.