TradingView market breadth guide

McClellan Oscillator on TradingView: formula and limits

The McClellan Oscillator measures market breadth momentum by subtracting a 39-day EMA from a 19-day EMA of net advances. Net advances are advancing issues minus declining issues across a specified market. The traditional calculation uses that count; a ratio-adjusted version divides it by advances plus declines before smoothing. On TradingView, verify the breadth feed, scale and daily calculation before comparing values. This page provides calculation examples, not a live market reading.

Draft a breadth indicator

Specify the breadth input before calculating the EMAs

Sherman and Marian McClellan developed the oscillator in 1969. Let A be advancing issues, D declining issues, and X the chosen breadth input. For each completed trading day, update the fast average as F = 0.10 × X + 0.90 × prior F, and the slow average as S = 0.05 × X + 0.95 × prior S. The oscillator is F − S. The prior EMA states must use the same input convention.

  • If A + D is zero, the ratio is undefined. If either input is missing, mark the observation unavailable; missing breadth is not neutral breadth.
  • Record the EMA seed rule and history start. ChartSchool's example seeds with simple averages; matching lengths alone does not match initialization.
ConventionDaily input XMeaning of the scale
TraditionalA − DNet issue count; the market's changing size affects amplitude.
Ratio-adjusted, scaled1000 × (A − D) / (A + D)Normalizes by advancing plus declining issues. Unchanged issues are excluded.
Ratio-adjusted, decimal(A − D) / (A + D)One-thousandth of the scaled version when history and initialization match.

Work through three hypothetical trading days

This arithmetic check assumes the scaled ratio-adjusted version and supplied prior states F = 100 and S = 80. Those states represent earlier history; the table does not claim to initialize 19-day and 39-day averages from three observations. Counts and dates are illustrative, not market data.

  • Day 1: F = 0.10 × 200 + 0.90 × 100 = 110; S = 0.05 × 200 + 0.95 × 80 = 86.
  • Day 2 has more declining than advancing issues, but the oscillator remains positive at 7.3. The sign depends on accumulated EMA states, not just today's A − D.
  • With 900 advances and 600 declines, the adjusted input would still be 200, while the traditional input would fall from 600 to 300. Normalization removes this proportional size difference.
  • Using decimal ratios and prior states 0.100 and 0.080 produces oscillator values 0.024, 0.0073 and −0.007015. A scale mismatch can explain a 1000-fold discrepancy.
ObservationA / DX = 1000 × (A − D) / (A + D)F / SF − S
Day 11800 / 1200200110 / 8624
Day 21200 / 1800−20079 / 71.77.3
Day 31200 / 1800−20051.1 / 58.115−7.015

Choose the market and verify its coverage

A breadth series describes its constituent universe. NYSE breadth, Nasdaq breadth and breadth restricted to an index are different inputs. McClellan Financial also distinguishes composite data from narrower common-stock series and notes differences between providers and final versus intraday figures. A script name is not enough to identify the dataset.

  • Confirm symbol availability and definitions in your TradingView account. Do not substitute similarly named symbols without inspecting their descriptions.
  • A stock or crypto chart does not automatically supply market-wide counts. Applying stock-market breadth to that chart is an external comparison, not breadth calculated from that asset.
  • A custom basket requires a defined membership history. Calculating historical breadth from today's constituents introduces a different population from the one that existed then.
CheckRecord before comparing charts
UniverseExchange or index, included issue types, and whether the feed is composite or filtered.
Source pairExact advancing and declining symbols, provider, and matching observation dates.
SessionDaily session boundary, time zone, publication time, and whether counts are final.
HistoryAvailable start date, missing observations, revisions and EMA initialization.

Check the TradingView calculation one bar at a time

Start on a daily chart with an inspectable McClellan Oscillator indicator. Record its source symbols, adjustment mode and EMA settings. Use the Data Window to compare a completed observation with your own input and EMA calculations, including the preceding states. If values differ, compare the inputs before changing the smoothing lengths.

  • Expose A, D, the chosen X, F and S alongside the oscillator during verification. Test a positive-breadth day, a negative-breadth day and a zero crossing.
  • Keep daily smoothing in a daily calculation context. Smoothing a daily value repeated across five-minute bars produces averages of repeated samples, not the intended daily sequence.
  • Specify developing daily values or the previous completed day. Closing an intraday chart bar does not complete the current daily observation.
  • Review request.security timing and gap handling. TradingView documents that filled gaps and unconfirmed higher-timeframe values can behave differently on historical and realtime bars.
  • For alerts, distinguish crossing zero from merely remaining above zero. Record when the breadth observation becomes available and test the alert on that same confirmation policy.

Read momentum without turning it into a price forecast

Zero crossings and divergences describe breadth conditions; they do not define a complete trade. The Day 2 example shows why a positive oscillator need not mean more stocks advanced today. Likewise, a lower positive reading means the EMA gap narrowed, not that an index must already be falling.

  • Avoid universal overbought or oversold numbers across traditional and adjusted series. Even a correctly matched threshold needs evaluation on the chosen market.
  • If testing a strategy, define entry timing, exits, position sizing and costs separately. Verify the indicator values first, then evaluate the trading rules on data not used to select them.
ObservationWhat it establishesWhat still needs checking
Cross above zeroF moved from at or below S to above S.The chosen confirmation time and a separate executable entry rule.
Price makes a higher high; oscillator makes a lower highPrice and breadth momentum diverge under the selected swing rule.Comparable dates, the market universe and subsequent price behavior.
An unusually large positive or negative readingAn extreme relative to the selected scale and reference history.The reference window; an extreme is not a guaranteed reversal.

Keep the oscillator separate from cumulative breadth lines

The Advance-Decline Line accumulates daily net advances. The McClellan Oscillator subtracts two smoothed breadth series. The McClellan Summation Index accumulates oscillator values under its chosen initialization and calibration. Their shapes and levels answer different questions; an A-D Line value cannot be substituted for net advances in the formula above.

SeriesUpdate or calculationQuestion
A-D LinePrior total + daily (A − D)How has cumulative participation changed?
McClellan OscillatorFast breadth EMA − slow breadth EMAHow do faster and slower breadth trends differ?
Summation IndexPrior index + oscillator, with the stated calibrationHow have oscillator readings accumulated?

Give Pineify a testable specification

Use the Pine Script AI Coding Agent to draft or explain an implementation after identifying the data feeds. Provide the source pair, daily observation policy, adjustment mode, scale, seed rule and missing-data behavior. Ask for diagnostic outputs so the generated result can be checked against the worked arithmetic.

  • Request explicit labels for the exchange and adjustment mode, plus a visible unavailable state for missing or invalid breadth inputs.
  • Ask for separate plots of the input and both averages during review, and a clear explanation of when zero-crossing alerts can fire.
  • Review the source, run syntax validation and compare completed daily values in TradingView. Compilation alone cannot establish feed correctness or trading performance.
Where Pineify fits

Pine Script AI Coding Agent

Draft a McClellan Oscillator with explicit breadth sources, adjustment and confirmation rules, then inspect its intermediate values in TradingView.

Draft a breadth indicator

Frequently asked questions

Educational information, not investment advice. All calculation examples are hypothetical. Breadth signals do not guarantee price direction or trading returns; data availability and confirmation timing depend on the selected feed.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.