OPEN-SOURCE SCRIPT
Telah dikemas kini

Smart Breadth [smartcanvas]

132
Overview
This indicator is a market breadth analysis tool focused on the S&P 500 index. It visualizes the percentage of S&P 500 constituents trading above their 50-day and 200-day moving averages, integrates the McClellan Oscillator for advance-decline analysis, and detects various breadth-based signals such as thrusts, divergences, and trend changes. The indicator is displayed in a separate pane and provides visual cues, a summary label with tooltip, and alert conditions to highlight potential market conditions.

The tool uses data symbols like S5FI (percentage above 50-day MA), S5TH (percentage above 200-day MA), ADVN/DECN (S&P advances/declines), and optionally NYSE advances/declines for certain calculations. If primary data is unavailable, it falls back to calculated breadth from advance-decline ratios.

This indicator is intended for educational and analytical purposes to help users observe market internals. My intention was to pack in one indicator things you will only find in a few. It does not provide trading signals as financial advice, and users are encouraged to use it in conjunction with their own research and risk management strategies. No performance guarantees are implied, and historical patterns may not predict future market behavior.
Key Components and Visuals

Plotted Lines:

  • Aqua line: Percentage of S&P 500 stocks above their 50-day MA.
  • Purple line: Percentage of S&P 500 stocks above their 200-day MA.
  • Optional orange line (enabled via "Show Momentum Line"): 10-day momentum of the 50-day MA breadth, shifted by +50 for scaling.
  • Optional line plot (enabled via "Show McClellan Oscillator"): McClellan Oscillator, colored green when positive and red when negative. Can use actual scale or normalized to fit breadth percentages (0-100).



Horizontal Levels:

  • Dotted green at 70%: "Strong" level.
  • Dashed green at user-defined green threshold (default 60%): "Buy Zone".
  • Dashed yellow at user-defined yellow threshold (default 50%): "Neutral".
  • Dotted red at 30%: "Oversold" level.
  • Optional dotted lines for McClellan (when shown and not using actual scale): Overbought (red), Oversold (green), and Zero (gray), scaled to fit.



Background Coloring:

  • Green shades for bullish/strong bullish states.
  • Yellow for neutral.
  • Orange for caution.
  • Red for bearish.



Signal Shapes:

  • Rocket emoji (🚀) at bottom for Zweig Breadth Thrust trigger.
  • Green circle at bottom for recovery signal.
  • Red triangle down at top for negative divergence warning.
  • Green triangle up at bottom for positive divergence.
  • Light green triangle up at bottom for McClellan oversold bounce.
  • Green diamond at bottom for capitulation signal.



Summary Label (Right Side):

Displays current action (e.g., "BUY", "HOLD") with emoji, breadth percentages with colored circles, McClellan value with emoji, market state, risk/reward stars, and active signals.
Hover tooltip provides detailed breakdown: action priority, breadth metrics, McClellan status, momentum/trend, market state, active signals, data quality, thresholds, recent changes, and a general recommendation category.


Calculations and Logic

  • Breadth Percentages: Derived from S5FI/S5TH or calculated from advances/(advances + declines) * 100, with fallback adjustments.
  • McClellan Oscillator: Difference between fast (default 19) and slow (default 39) EMAs of net advances (advances - declines).
  • Momentum: 10-day change in 50-day MA breadth percentage.
  • Trend Analysis: Counts consecutive rising days in breadth to detect upward trends.
  • Breadth Thrust (Zweig): 10-day EMA of advances/total issues crossing from below a bottom level (default 40) to above a top level (default 61.5). Can use S&P or NYSE data.
  • Divergences: Compares S&P 500 price highs/lows with breadth or McClellan over a lookback period (default 20) to detect positive (bullish) or negative (bearish) divergences.
  • Market States: Determined by breadth levels relative to thresholds, trend direction, and McClellan conditions (e.g., strong bullish if above green threshold, rising, and McClellan supportive).
  • Actions: Prioritized logic (0-10) selects an action like "BUY" or "AVOID LONGS" based on signals, states, and conditions. Higher priority (e.g., capitulation at 10) overrides lower ones.
  • Alerts: Triggered on new occurrences of key conditions, such as breadth thrust, divergences, state changes, etc.


Input Parameters
The indicator offers customization through grouped inputs, but the use of defaults is encouraged.


Usage Notes
Add the indicator to a chart of any symbol (though designed around S&P 500 data; works best on daily or higher timeframes). Monitor the label and tooltip for a consolidated view of conditions. Set up alerts for specific events.

This script relies on external security requests, which may have data availability issues on certain exchanges or timeframes. The fallback mechanism ensures continuity but may differ slightly from primary sources.

Disclaimer
This indicator is provided for informational and educational purposes only. It does not constitute investment advice, financial recommendations, or an endorsement of any trading strategy. Market conditions can change rapidly, and users should not rely solely on this tool for decision-making. Always perform your own due diligence, consult with qualified professionals if needed, and be aware of the risks involved in trading. The author and TradingView are not responsible for any losses incurred from using this script.
Nota Keluaran
Added VIX for capitulation signals.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.