Advance/Decline Line on TradingView: Formula and Limits
The advance decline indicator measures participation across a defined group of stocks. The standard line accumulates advancing stocks minus declining stocks. Before interpreting it, identify the market, the count definitions and the formula: a price-based proxy or a transformed breadth series will produce a different result.
Standard cumulative breadth
Net advances = A − D
ADL today = ADL yesterday + net advances
A and D are stock counts for the same universe and observation interval. The retained Pine example below uses an unchanged-adjusted square-root variant; it is labeled separately.
Educational indicator reference. No return forecast or investment recommendation.
A four-session example: counts, cumulative value and baseline
Assume a fixed universe of 1,000 stocks. Classify each close against its previous session close, with unchanged stocks in a separate group. These invented counts demonstrate arithmetic; they are not market data or a backtest.
| Session | Advances | Declines | Unchanged | A − D | Start 0 | Start 10,000 |
|---|---|---|---|---|---|---|
| 1 | 600 | 350 | 50 | +250 | 250 | 10,250 |
| 2 | 420 | 530 | 50 | -110 | 140 | 10,140 |
| 3 | 480 | 480 | 40 | 0 | 140 | 10,140 |
| 4 | 350 | 600 | 50 | -250 | -110 | 9,890 |
The fourth session ends at 250 − 110 + 0 − 250 = −110 from a zero start. Starting at 10,000 gives 9,890 with identical daily changes. A zero crossing therefore depends on the baseline. Moving the start date also removes earlier contributions; compare changes over a shared interval before comparing absolute levels.
If session 2 is missing, its −110 contribution is unknown. Replacing it with zero would leave the displayed total 110 too high from that point onward. A flat line can mean equal counts, a held previous value or missing observations; inspect the inputs to distinguish them.
The raw accumulation rule follows TradingView's Advance/Decline Line definition. The table and baseline comparison are worked examples.
Pine Script: what the retained example actually calculates
This script requests NYSE advancing, declining and unchanged series through a synthetic symbol expression. The requested close is the value of that expression, not the price of the chart ticker. It plots transformed market breadth and contains no divergence labels, alerts or strategy orders.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Pineify
//@version=6
indicator(title="Advance Decline Line", overlay=false, max_labels_count=500)
// ADL calculation: square-root weighted cumulative sum of NYSE breadth data
adlCalc(difference) => ta.cum(difference > 0 ? math.sqrt(difference) : -math.sqrt(-difference))
p_ta_advance_decline_line() =>
adl = request.security("(USI:ADVN.NY - USI:DECL.NY) / (USI:UNCH.NY + 1)", timeframe.period, adlCalc(close))
adl
p_ind_1 = p_ta_advance_decline_line()
plot(p_ind_1, "ADL", color.rgb(41, 98, 255, 0), 2)Do not compare this output directly with the raw-count table.
Here, x = (A − D) / (U + 1), and each contribution is sign(x) × √|x|. Session 1 gives 250 / 51 ≈ 4.902, then √4.902 ≈ 2.214 instead of +250. Removing only the square root still leaves the unchanged-stock denominator. U + 1 is not the total number of stocks.
Inputs and behavior to inspect
USI:ADVN.NYandUSI:DECL.NYidentify NYSE series. Changing the chart from SPY to QQQ does not change that universe.timeframe.periodfollows the chart interval. For the daily calculation described here, use a daily chart. A weekly sample of counts is not the sum of five daily net counts.ta.cum()runs inside the requested context, over its available history. The script has no fixed start-date input and no baseline control.- The request uses default gap handling and has no completeness test. A held value does not prove there was a new observation; an unavailable symbol can stop execution.
- There is no bar-close confirmation rule. Treat the current value as provisional until the relevant source bar closes, and account for later provider corrections.
Source identities: NYSE advancing and NYSE declining. Request behavior: TradingView's data-context documentation. A syntax check does not confirm feed availability or matching live values.
How to use the advance decline indicator on TradingView
- Choose a universe before choosing a benchmark. NYSE listings and S&P 500 constituents are different groups. An NYSE line beside SPY provides broad context but is not an exact count of SPY holdings.
- Open the requested series in TradingView and check dates, interval, provider coverage and permissions. Record how unchanged issues and changes in constituents are treated.
- Paste the example into the Pine Editor and add it to a daily chart. Check several closed bars against the synthetic expression before interpreting slopes.
- Compare scripts by inspecting their source. A calculation based only on the current symbol's rising and falling bars is a price-path statistic. It cannot establish how many stocks advanced across an exchange.
- For a custom raw ADL, specify A − D accumulation, a start date, a baseline and a missing-data policy. Mark incomplete periods and suspend signals until continuity is verified. Do not silently convert missing counts to zero.
TradingView's Advance/Decline Ratio (Bars) explicitly counts bars of the current symbol. That is a separate measurement from market breadth.
Divergence needs a comparison rule
An index higher high with a lower breadth high shows disagreement over the selected interval. It does not supply an entry date, reversal probability or exit. A capitalization-weighted index and an equal-count breadth series can disagree for an extended period. A universe mismatch can also explain the difference.
For a repeatable check, specify the two price highs, the matching breadth observations and the confirmation bar. If a pivot needs later bars, an alert is available only after those bars arrive. The retained plotting script does not implement this rule.
Advance/Decline Line vs McClellan and other ADL names
| Measure | Calculation | What differs |
|---|---|---|
| Raw Advance/Decline Line | Running total of A − D | Accumulates net participation; baseline is arbitrary. |
| McClellan Oscillator | EMA19(A − D) − EMA39(A − D) | Difference between fast and slow breadth averages; ratio-adjusted variants use a different input. |
| Advance/Decline Ratio | A / D | A per-period ratio, not a cumulative total. Undefined when D is zero. |
| Accumulation/Distribution | Cumulative close-location-weighted volume | Uses one instrument's price and volume rather than stock counts. |
McClellan's 10% and 5% EMA smoothing constants correspond to lengths 19 and 39 under α = 2 / (length + 1). Its Summation Index accumulates oscillator values; it is not the raw ADL. Match raw or ratio-adjusted inputs before comparing implementations.
References: McClellan's own calculation explanation, TradingView A/D Ratio, and TradingView Accumulation/Distribution.
Write a checkable breadth specification in Pineify
Use the Pine Script AI Coding Agent to describe the input series and expected behavior. The following specification makes the difference between raw counts and the retained variant explicit.
Build a Pine Script v6 daily NYSE Advance/Decline Line from verified advancing and declining count symbols. Accumulate raw A minus D, with a configurable start date and zero baseline. Show source counts for bar-by-bar comparison. Mark missing data and suspend signals through incomplete history. Explain confirmation timing. Keep the square-root variant separate and do not infer divergence alerts from the plotted line alone.
Check syntax and several closed-bar values before adding trading rules. A strategy also needs exits, position sizing, costs and an out-of-sample evaluation; an indicator plot does not provide those decisions.
Open Pine Script AI Coding AgentFrequently asked questions
Sources and script reviewed October 17, 2026. Data availability can vary by account and provider.