OPEN-SOURCE SCRIPT
Zweig Breadth Thrust + Divergence

█ OVERVIEW
This indicator implements Martin Zweig's Breadth Thrust signal and adds a pivot-based breadth divergence detector. The thrust identifies rare, high-conviction moments when the market shifts explosively from oversold to overbought breadth within a compressed time window. The divergence layer provides ongoing analytical value between thrust events by flagging when price and breadth participation diverge at swing points.
The formula follows Greg Morris's documentation in The Complete Guide to Market Breadth Indicators (2nd ed., 2015), Chapter 5. All parameters match Zweig's original specification and are configurable for experimentation.
═══════════════════════════════════════════════════════════════════
█ ZWEIG BREADTH THRUST
Formula
Pine Script®
The indicator uses NYSE advancing and declining issues via USI:ADV and USI:DECL.
Signal logic
The thrust is a state machine with three phases:
• ARMED: The ratio EMA drops below 0.40, indicating deeply oversold breadth. The indicator begins counting bars.
• THRUST: If the ratio EMA then rises above 0.615 within 10 bars, the thrust signal fires. A green triangle marks the bar where the signal completes.
• FAILED: If 10 bars elapse without the ratio EMA reaching 0.615, the window expires and the indicator returns to idle. It must drop below 0.40 again to re-arm.
If the ratio EMA drops below 0.40 again while already armed, the bar counter resets. Per Morris: "Once it moves from below 0.4 to above it, the signal occurs when it then moves above 0.615. If it has not done that within 10 days it has to start over from below 0.4."
An orange background highlights bars where the indicator is in the armed state.
Historical context
Thrust signals are rare. Morris documents 8 occurrences between 1965 and 2014: December 1971, October 1974, January 1975, August 1982, August 1984, March 2009, October 2011, and October 2013. Additional signals have fired since, including November 2023 and April 2025. Zweig's research found an average gain of 24.6% in the 11 months following a thrust, and most bull markets begin with one.
═══════════════════════════════════════════════════════════════════
█ BREADTH DIVERGENCE
The divergence detector identifies when the reference index price and the breadth ratio EMA disagree at swing points:
• Bearish divergence: Price makes a higher swing high while the ratio EMA makes a lower swing high. Participation is narrowing even as price pushes to new highs.
• Bullish divergence: Price makes a lower swing low while the ratio EMA makes a higher swing low. Breadth is improving even as price deteriorates.
Swing highs and lows are identified using pivot detection with a configurable lookback (default: 5 bars left and right). Price and ratio pivots are tracked independently so they do not need to occur on the same bar. When a new ratio pivot is confirmed, it is compared against the two most recent price pivots (and vice versa) to identify the divergence pattern.
Divergences are drawn as dashed lines connecting the two ratio pivot points, with a label at the current pivot. Red dashed lines indicate bearish divergences; green dashed lines indicate bullish divergences.
═══════════════════════════════════════════════════════════════════
█ INDEX OVERLAY
The Reference Index setting controls which price series is used for divergence detection:
• NYSE Composite (default): Uses INDEX:NYA. The natural pairing since the breadth data is NYSE-sourced.
• S&P 500: Uses SP:SPX. Useful for detecting divergences between NYSE breadth and S&P 500 price, which can reveal when the large-cap index is masking broader weakness.
Important: The thrust calculation always uses NYSE breadth data regardless of the index selection. TradingView does not provide S&P 500-specific advance/decline feeds. The index toggle only affects which price series the divergence detector compares against the breadth ratio.
═══════════════════════════════════════════════════════════════════
█ STATUS TABLE
A status table (position configurable) displays:
• Ratio EMA: Current value of the 10-period EMA of the breadth ratio. Color-coded green above the thrust threshold, red below the armed threshold, gray between.
• State: ARMED (orange) when the ratio EMA has dropped below 0.40 and the thrust window is open, or IDLE (gray) otherwise.
• Bars Left: Remaining bars in the thrust window before expiration.
• Last Thrust: How many bars ago the most recent thrust signal fired, or "None visible" if none has occurred in the loaded chart history.
═══════════════════════════════════════════════════════════════════
█ ALERTS
Five alert conditions are available:
• Thrust Completed: The ratio EMA moved from below 0.40 to above 0.615 within the thrust window.
• Thrust Armed: The ratio EMA dropped below 0.40, opening the thrust window.
• Thrust Failed: The thrust window expired without the ratio EMA reaching 0.615.
• Bearish Divergence: Price made a higher high while the breadth ratio EMA made a lower high.
• Bullish Divergence: Price made a lower low while the breadth ratio EMA made a higher low.
═══════════════════════════════════════════════════════════════════
█ SETTINGS
Zweig Breadth Thrust
• EMA Length: Period for the exponential moving average of the breadth ratio. Default: 10.
• Low Threshold (Armed): The ratio EMA must drop below this level to arm the thrust. Default: 0.40.
• High Threshold (Thrust): The ratio EMA must rise above this level to complete the thrust. Default: 0.615.
• Thrust Window (bars): Maximum number of bars allowed between arming and thrust completion. Default: 10.
Divergence Detection
• Pivot Lookback: Number of bars to the left and right for pivot detection. Default: 5.
• Show Divergences: Toggle divergence lines and labels on or off.
Index Overlay
• Reference Index: NYSE Composite or S&P 500. Controls which price series is used for divergence detection.
Display
• Show Status Table: Toggle the status table.
• Show Armed Background: Toggle the orange background highlight during armed windows.
• Table Position: Top-right, top-left, bottom-right, or bottom-left.
═══════════════════════════════════════════════════════════════════
█ METHODOLOGY NOTES
Morris tested modifications to Zweig's original parameters, including substituting a simple moving average for the EMA and shortening the EMA period to 8. Neither improved results. The defaults in this indicator match the canonical formulation.
The divergence detector uses the breadth ratio EMA (not price) as the primary series for drawing lines. This keeps all visual elements in the indicator's own pane. The price comparison happens internally using pivots from the selected reference index.
This indicator is designed for daily charts. On intraday timeframes, the breadth data resolves to daily values via request.security, so the thrust logic will still operate on daily bars regardless of the chart timeframe.
═══════════════════════════════════════════════════════════════════
█ PROVENANCE AND ATTRIBUTION
The Zweig Breadth Thrust is universally attributed to Martin Zweig (1942-2013), who published The Zweig Forecast newsletter from 1971 to 1997 and wrote Winning on Wall Street (Warner Books, 1986; revised edition 1994). The specific 0.40 / 0.615 / 10-day formulation does not appear in the 1986 first edition but is present in the 1994 revised edition (pp. 121-129). Whether the indicator was first published in the book or in the newsletter is unclear from available sources.
The formula documented in this indicator follows Greg Morris, The Complete Guide to Market Breadth Indicators (2nd ed., 2015), Chapter 5: Advance-Decline Ratio Indicators. Morris credits Zweig as the creator and provides the most rigorous published documentation of the methodology, including his own commentary on common misimplementations.
Additional references:
• Arthur Hill, StockCharts.com commentary on the Zweig Breadth Thrust (2023)
• Tom McClellan, McClellan Financial Publications
This indicator implements Martin Zweig's Breadth Thrust signal and adds a pivot-based breadth divergence detector. The thrust identifies rare, high-conviction moments when the market shifts explosively from oversold to overbought breadth within a compressed time window. The divergence layer provides ongoing analytical value between thrust events by flagging when price and breadth participation diverge at swing points.
The formula follows Greg Morris's documentation in The Complete Guide to Market Breadth Indicators (2nd ed., 2015), Chapter 5. All parameters match Zweig's original specification and are configurable for experimentation.
═══════════════════════════════════════════════════════════════════
█ ZWEIG BREADTH THRUST
Formula
The indicator uses NYSE advancing and declining issues via USI:ADV and USI:DECL.
Signal logic
The thrust is a state machine with three phases:
• ARMED: The ratio EMA drops below 0.40, indicating deeply oversold breadth. The indicator begins counting bars.
• THRUST: If the ratio EMA then rises above 0.615 within 10 bars, the thrust signal fires. A green triangle marks the bar where the signal completes.
• FAILED: If 10 bars elapse without the ratio EMA reaching 0.615, the window expires and the indicator returns to idle. It must drop below 0.40 again to re-arm.
If the ratio EMA drops below 0.40 again while already armed, the bar counter resets. Per Morris: "Once it moves from below 0.4 to above it, the signal occurs when it then moves above 0.615. If it has not done that within 10 days it has to start over from below 0.4."
An orange background highlights bars where the indicator is in the armed state.
Historical context
Thrust signals are rare. Morris documents 8 occurrences between 1965 and 2014: December 1971, October 1974, January 1975, August 1982, August 1984, March 2009, October 2011, and October 2013. Additional signals have fired since, including November 2023 and April 2025. Zweig's research found an average gain of 24.6% in the 11 months following a thrust, and most bull markets begin with one.
═══════════════════════════════════════════════════════════════════
█ BREADTH DIVERGENCE
The divergence detector identifies when the reference index price and the breadth ratio EMA disagree at swing points:
• Bearish divergence: Price makes a higher swing high while the ratio EMA makes a lower swing high. Participation is narrowing even as price pushes to new highs.
• Bullish divergence: Price makes a lower swing low while the ratio EMA makes a higher swing low. Breadth is improving even as price deteriorates.
Swing highs and lows are identified using pivot detection with a configurable lookback (default: 5 bars left and right). Price and ratio pivots are tracked independently so they do not need to occur on the same bar. When a new ratio pivot is confirmed, it is compared against the two most recent price pivots (and vice versa) to identify the divergence pattern.
Divergences are drawn as dashed lines connecting the two ratio pivot points, with a label at the current pivot. Red dashed lines indicate bearish divergences; green dashed lines indicate bullish divergences.
═══════════════════════════════════════════════════════════════════
█ INDEX OVERLAY
The Reference Index setting controls which price series is used for divergence detection:
• NYSE Composite (default): Uses INDEX:NYA. The natural pairing since the breadth data is NYSE-sourced.
• S&P 500: Uses SP:SPX. Useful for detecting divergences between NYSE breadth and S&P 500 price, which can reveal when the large-cap index is masking broader weakness.
Important: The thrust calculation always uses NYSE breadth data regardless of the index selection. TradingView does not provide S&P 500-specific advance/decline feeds. The index toggle only affects which price series the divergence detector compares against the breadth ratio.
═══════════════════════════════════════════════════════════════════
█ STATUS TABLE
A status table (position configurable) displays:
• Ratio EMA: Current value of the 10-period EMA of the breadth ratio. Color-coded green above the thrust threshold, red below the armed threshold, gray between.
• State: ARMED (orange) when the ratio EMA has dropped below 0.40 and the thrust window is open, or IDLE (gray) otherwise.
• Bars Left: Remaining bars in the thrust window before expiration.
• Last Thrust: How many bars ago the most recent thrust signal fired, or "None visible" if none has occurred in the loaded chart history.
═══════════════════════════════════════════════════════════════════
█ ALERTS
Five alert conditions are available:
• Thrust Completed: The ratio EMA moved from below 0.40 to above 0.615 within the thrust window.
• Thrust Armed: The ratio EMA dropped below 0.40, opening the thrust window.
• Thrust Failed: The thrust window expired without the ratio EMA reaching 0.615.
• Bearish Divergence: Price made a higher high while the breadth ratio EMA made a lower high.
• Bullish Divergence: Price made a lower low while the breadth ratio EMA made a higher low.
═══════════════════════════════════════════════════════════════════
█ SETTINGS
Zweig Breadth Thrust
• EMA Length: Period for the exponential moving average of the breadth ratio. Default: 10.
• Low Threshold (Armed): The ratio EMA must drop below this level to arm the thrust. Default: 0.40.
• High Threshold (Thrust): The ratio EMA must rise above this level to complete the thrust. Default: 0.615.
• Thrust Window (bars): Maximum number of bars allowed between arming and thrust completion. Default: 10.
Divergence Detection
• Pivot Lookback: Number of bars to the left and right for pivot detection. Default: 5.
• Show Divergences: Toggle divergence lines and labels on or off.
Index Overlay
• Reference Index: NYSE Composite or S&P 500. Controls which price series is used for divergence detection.
Display
• Show Status Table: Toggle the status table.
• Show Armed Background: Toggle the orange background highlight during armed windows.
• Table Position: Top-right, top-left, bottom-right, or bottom-left.
═══════════════════════════════════════════════════════════════════
█ METHODOLOGY NOTES
Morris tested modifications to Zweig's original parameters, including substituting a simple moving average for the EMA and shortening the EMA period to 8. Neither improved results. The defaults in this indicator match the canonical formulation.
The divergence detector uses the breadth ratio EMA (not price) as the primary series for drawing lines. This keeps all visual elements in the indicator's own pane. The price comparison happens internally using pivots from the selected reference index.
This indicator is designed for daily charts. On intraday timeframes, the breadth data resolves to daily values via request.security, so the thrust logic will still operate on daily bars regardless of the chart timeframe.
═══════════════════════════════════════════════════════════════════
█ PROVENANCE AND ATTRIBUTION
The Zweig Breadth Thrust is universally attributed to Martin Zweig (1942-2013), who published The Zweig Forecast newsletter from 1971 to 1997 and wrote Winning on Wall Street (Warner Books, 1986; revised edition 1994). The specific 0.40 / 0.615 / 10-day formulation does not appear in the 1986 first edition but is present in the 1994 revised edition (pp. 121-129). Whether the indicator was first published in the book or in the newsletter is unclear from available sources.
The formula documented in this indicator follows Greg Morris, The Complete Guide to Market Breadth Indicators (2nd ed., 2015), Chapter 5: Advance-Decline Ratio Indicators. Morris credits Zweig as the creator and provides the most rigorous published documentation of the methodology, including his own commentary on common misimplementations.
Additional references:
• Arthur Hill, StockCharts.com commentary on the Zweig Breadth Thrust (2023)
• Tom McClellan, McClellan Financial Publications
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.