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)
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。