New High / New Low Breadth
A breadth indicator that counts how many securities in a user-defined basket are trading at new highs or new lows over a specified period, then displays the advance-decline reading. Breadth analysis measures the participation and health of a move: sustained uptrends show increasing new highs relative to new lows, while divergences, price making new highs as new lows widen, often precede reversals. Traders use breadth to cross-check whether a single symbol's move has broad support or is narrow and fragile.
//@version=6
indicator("New High / New Low Breadth", overlay=false, max_bars_back=500)
// ===== User inputs =====
sym1 = input.symbol("AAPL", "Symbol 1")
sym2 = input.symbol("MSFT", "Symbol 2")
sym3 = input.symbol("GOOGL", "Symbol 3")
sym4 = input.symbol("AMZN", "Symbol 4")
sym5 = input.symbol("TSLA", "Symbol 5")
sym6 = input.symbol("NVDA", "Symbol 6")
period = input.int(252, "Period (bars)", minval=20, maxval=1000)
smoothLen = input.int(10, "Smoothing length", minval=1, maxval=100)
// ===== Fetch data for each symbol =====
close1 = request.security(sym1, timeframe.period, close)
close2 = request.security(sym2, timeframe.period, close)
close3 = request.security(sym3, timeframe.period, close)
close4 = request.security(sym4, timeframe.period, close)
close5 = request.security(sym5, timeframe.period, close)
close6 = request.security(sym6, timeframe.period, close)
// ===== Count new highs and new lows =====
// A new high: current close >= highest close over past [period] bars
// A new low: current close <= lowest close over past [period] bars
newHighs = 0
newLows = 0
if close1 >= ta.highest(close1, period) then newHighs += 1
if close1 <= ta.lowest(close1, period) then newLows += 1
if close2 >= ta.highest(close2, period) then newHighs += 1
if close2 <= ta.lowest(close2, period) then newLows += 1
if close3 >= ta.highest(close3, period) then newHighs += 1
if close3 <= ta.lowest(close3, period) then newLows += 1
if close4 >= ta.highest(close4, period) then newHighs += 1
if close4 <= ta.lowest(close4, period) then newLows += 1
if close5 >= ta.highest(close5, period) then newHighs += 1
if close5 <= ta.lowest(close5, period) then newLows += 1
if close6 >= ta.highest(close6, period) then newHighs += 1
if close6 <= ta.lowest(close6, period) then newLows += 1
// ===== Compute breadth readings =====
// Advance / Decline line: new highs minus new lows
advanceLine = newHighs - newLows
// Total breadth: new highs plus new lows (participation)
totalBreadth = newHighs + newLows
// Smooth the A/D line for trend visibility
advanceSmooth = ta.ema(advanceLine, smoothLen)
// ===== Plot outputs =====
plot(advanceLine, "A/D Line (raw)", color.new(color.blue, 0), linewidth=1)
plot(advanceSmooth, "A/D Line (smoothed)", color.new(color.navy, 0), linewidth=2)
hline(0, "Zero line", color.gray, linestyle=hline.style_dashed)
barcolor(advanceLine > 0 ? color.new(color.green, 70) : color.new(color.red, 70))
How the code works
The script accepts six symbols as inputs (AAPL, MSFT, GOOGL, AMZN, TSLA, NVDA by default) and pulls their closing prices using request.security(), which reads data from each symbol without repainting. For each symbol, the code compares the current close to the highest and lowest closes over a user-specified period (default 252 bars, roughly one year on a daily chart). If the current close is greater than or equal to the period high, that symbol logs a new high; if it is less than or equal to the period low, it logs a new low. (A symbol can register both simultaneously at extreme turning points, or neither if it trades in the middle of its range.)
The script sums the new highs and new lows across all six symbols. The core breadth reading is the advance-decline line: new highs minus new lows, which oscillates around zero. A positive reading means more securities are at new highs than new lows (a bullish breadth environment); a negative reading signals more new lows than new highs (bearish breadth). The script also plots an EMA-smoothed version to reveal the underlying trend without noise. Bar color reflects the raw A/D reading, turning green when positive and red when negative.
Reading it on a chart
Breadth divergences are the primary signal. If a benchmark index or your tracked symbol is making new highs while the new high/new low count declines or rolls over, it suggests the rally is narrowing, driven by a shrinking subset of the basket, and is at risk of losing momentum. Conversely, when new highs accelerate into new market lows, breadth weakness foreshadows price weakness.
Strong uptrends typically show the A/D line rising alongside price. A flat or declining A/D line during a price rally, especially if new lows widen, is a common warning of exhaustion. The smoothed line helps distinguish short-term noise from structural breadth deterioration.
The total breadth (new highs plus new lows) separately shows participation: high readings mean many securities are testing extremes; low readings suggest most of the basket is stuck in the middle of its range. A sudden collapse in total breadth can signal indecision or a market state change.
Limitations
This indicator has several critical constraints. First, it is a proxy only: breadth across six chosen symbols does not represent the true market breadth (which would require data from hundreds of stocks). The choice of symbols introduces selection bias; users must curate their basket intentionally or risk a misleading picture.
Second, the period parameter (default 252) is arbitrary. A 252-bar lookback on daily data represents one calendar year, but optimal periods vary by market regime, asset class and chart timeframe. A symbol can register a new high every single bar in a sustained bull run, making counts repetitive; conversely, in choppy sideways markets, highs and lows flip-flop without predictive value.
Third, Pine Script's ta.highest() and ta.lowest() functions look backward, not forward, so there is no look-ahead bias within a bar. However, the indicator repaints if the user later adjusts the period parameter or changes symbols, which is a user-driven risk rather than a code defect.
Fourth, new highs and new lows are binary counts (present or absent) and ignore magnitude. A security at exactly a new high of 0.01% registers the same as one at a 30% new high, inflating the signal. Weighting by price change or volatility would require additional complexity.
Fifth, survivorship bias: if a symbol in the basket is delisted, splits, or becomes illiquid, request.security() may return stale or NA data without clear warning. The user must monitor their symbol list.
Finally, breadth divergences are suggestive but not deterministic. Markets can diverge for weeks and still resolve in the direction the narrow set of leaders dictated, making false reversals common. This tool refines entries and exits; it does not generate standalone trading signals.
Key definitions
Breadth: The measure of how many securities in a basket or index are participating in a move, expressed as the count or ratio of advancing vs. declining securities or new highs vs. new lows.
Advance-Decline line: A cumulative or period-by-period measure of the difference between the number of securities making new highs and those making new lows; used to assess market momentum and divergence.
New high: A security's current price at or above its highest price over a specified historical period (e.g., 52-week high on a daily chart).
New low: A security's current price at or below its lowest price over a specified historical period.
Divergence: A situation in which price trends upward or downward while breadth or momentum indicators weaken or move in the opposite direction; often a sign of trend fatigue.
Repainting: An indicator calculation that recalculates and changes past bar values on revisits, introducing false signals and undermining backtests; avoided in this code by using closed bars only.
References
- Advance-Decline Line (A/D Line), Investopedia. Accessed 2026. [Explains daily advances vs. declines and cumulative interpretation.]
- Technical Analysis from A to Z, Bulkowski, T., Wiley (2002). [Breadth indicators and divergence theory.]
- New Highs and New Lows, MarketSmith / IBD Research. [Practitioner application of new high/low breadth in US equities.]
- Positive Volume Index, Norman Fosback, Institute for Econometric Research (1976). [Historical breadth methodology.]
- Pine Script Documentation: request.security(), TradingView. [Function reference for multi-symbol data retrieval.]
Educational research on historical data only. Not investment advice, not a signal, and never a performance promise. Past results do not predict future performance. Every reference is link-verified before publication and every paper is re-audited weekly against the library's editorial standard.
Last reviewed by the PropLedger research pipeline: 2026-10-18. Educational research on historical data, not financial advice.
Keep reading
Spread Tracker: Two Futures Contracts
Free open-source Pine Script indicator: spread tracker between two related futures contracts. Full code and a plain-English walkthrough.
Floor vs Camarilla Pivot Points
Free open-source Pine Script indicator: pivot points: floor trader vs Camarilla comparison. Full code and a plain-English walkthrough.
Average Daily Range Percentage Tracker with Alerts
Free open-source Pine Script indicator: average daily range percentage tracker with alerts. Full code and a plain-English walkthrough.