Record Close Breadth

413
█ OVERVIEW

Record Close Breadth plots, in a separate pane, a breadth rank that is taken only on days when the index closes at a new all-time high and held flat until the next record close. The thesis is that a cap-weighted index can keep setting records while a shrinking share of its members remains in an uptrend, and that this condition is easier to judge when each record is compared with earlier records rather than with every day.

The rank is the percentile, among earlier record closes, of how few S&P 500 members were above their 200-day moving average on the record day. A rank of 100 means fewer members were above their 200-day average than on any earlier ranked record close.


█ HISTORY / BACKGROUND

Non-confirmation between an index and its members is a long-standing principle of breadth analysis, going back to the Dow Theory practice of requiring the averages to confirm one another. In an October 2026 study, Michael Burry measured, on each S&P 500 record close since 1985, the share of index members more than 20% below their own ten-year highs, and a narrower share of members more than 20% below a ten-year high set within the prior two years. His counts are built from full constituent price histories, which Pine cannot load.

This script keeps the record-day framing and substitutes an index-level series that the platform carries, the percent of S&P 500 members above their 200-day moving average. It does not reproduce his measures. The ranking of each record against earlier records, the source staleness control and the episode comparison are original to this script.

The conceptual basis is that a record close holds the index level constant. Comparing breadth across record closes therefore asks how many members took part in each new high, without the comparison being distorted by where the index stood.


█ HOW IT WORKS

1. Four request.security() calls on the daily timeframe return, from each source symbol, its close and its bar time: the index (default SP:SPX), the percent of S&P 500 members above their 200-day average (default INDEX:S5TH), the S&P 500 equal-weight index (default SP:SPW), and the count of S&P 500 members at new 52-week highs (default INDEX:MAHP). The equal-weight request also returns its drawdown, the close divided by the highest close of the last 504 equal-weight sessions, minus 1.
2. Lookahead is off for the index, percent-above-200-day and new-highs requests. It is on for the equal-weight request, because that feed stamps each daily bar at the prior evening UTC and lookahead off would return the previous session's close. With lookahead on, the value returned is the equal-weight close of the same trading session as the chart bar.
3. A new index session is detected when the requested index bar time changes. A session counter advances on each one.
4. For each breadth source, a function counts index sessions since the source's bar time last changed. When that count exceeds the stale limit, the source is treated as missing for that session.
5. A record close is an index close above the running maximum of earlier index closes. The first loaded bar counts as a record unless a seed applies. When the index is SP:SPX or TVC:SPX, the seed option is on, and the first loaded bar falls on or after 2000-03-25 and before 2007-05-31, the running maximum starts at 1527.46, the 2000-03-24 close.
6. On a record close dated on or after the ranking history start, the percent-above-200-day reading is ranked against an array of earlier ranked record-day readings. The rank equals 100 times the share of earlier readings that are higher, with equal readings counted as one half. The rank is na when fewer than the minimum number of earlier readings exist. The reading is then appended to the array.
7. The equal-weight drawdown is ranked the same way against its own array, with a larger drawdown ranking higher. This rank is used only in the table and the data window.
8. A record close that arrives at least the episode gap in index sessions after the previous record close starts a new episode. At that point the breadth rank of the previous episode's last record is stored.
9. The narrowing flag is true on a record close whose breadth rank is above the stored rank of the previous episode's last record.
10. The breadth rank of the latest record close is held until the next record close. A narrow record is one whose breadth rank is at or above the narrow threshold.


█ HOW TO USE

Apply the script to a 1D chart of SP:SPX. The logic is designed for the daily timeframe because records, sessions, episodes and staleness are all counted on daily closes, and the script stops with a runtime error on any other timeframe.

The purple step line is the breadth rank of the most recent record close. It changes only on record closes. A dot marks each record close at its rank: red at or above the narrow threshold, orange from 75 up to the threshold, and gray below 75 or when the rank is na. The dashed red line is the narrow threshold and the dotted gray line is 50. The pane background is shaded red while the held rank is at or above the threshold, so shading that continues through a decline means the last record before the decline was narrow. It does not describe the decline.

A run of record closes whose ranks rise from one episode to the next is a narrowing sequence. The narrowing flag and its alert mark the record closes where this occurs.

With Show status table on, a table in the top right corner reports, for the latest record close, its date, the breadth rank and whether it is narrow or ordinary, the percent above the 200-day average, the equal-weight drawdown and its rank, the new 52-week highs count, the previous episode's last rank, whether the sequence is narrowing, the number of ranked readings in each array, and the sessions elapsed since the record. It adds a warning row when the loaded SP:SPX history begins on or after 2007-05-31.

The data window lists, on each record close, a record flag, the percent above the 200-day average, the equal-weight drawdown in percent, both ranks, the breadth rank, the new-highs count and the narrowing flag.

Two alert conditions are available, Narrow record close and Narrowing record sequence.


█ SETTINGS

Sources
 • Index sets the symbol whose daily closes define record closes. Default SP:SPX.
 • Percent of members above 200-day sets the breadth series that is ranked. Default INDEX:S5TH.
 • Equal-weight index (table only) sets the series whose drawdown is shown as context. Default SP:SPW.
 • New 52-week highs (table only) sets the new-highs count shown as context. Default INDEX:MAHP.

Logic
 • Narrow record threshold, breadth rank sets the rank at or above which a record close is narrow, from 0 to 100. Default 96.15.
 • Episode gap, sessions sets how many index sessions after the previous record close a record close must arrive to start a new episode. Default 20.
 • Stale source limit, sessions sets how many index sessions a breadth source may go without a new bar before it is treated as missing. Default 5.
 • Equal-weight high lookback, sessions sets the window for the equal-weight high used in the drawdown. Default 504.
 • Minimum prior records for ranking sets how many earlier ranked readings a rank requires. Default 50.
 • Ranking history start sets the date before which record closes neither enter the ranking arrays nor receive a rank. Default 2007-01-01.
 • Seed the 2000 closing high when history is short turns the SP:SPX running-maximum seed on or off. Default on.

Display
 • Show status table shows or hides the table. Default off.
 • Debug: plot raw source values plots the percent above the 200-day average and the equal-weight drawdown in percent on every bar, and adds the equal-weight close to the data window. Default off.


█ WHAT MAKES IT ORIGINAL

Breadth tools usually compare breadth with price on every bar or flag divergences at swing highs. This script samples breadth only on index record closes and ranks each sample against the earlier record closes, so the reference distribution is the market's own history of record days rather than all days. A reading is therefore judged against conditions at comparable index highs.

It also groups record closes into episodes and compares each record with the last record of the previous episode, which separates a series of records that is broadening from one that is narrowing.

The four sources are combined for one purpose. The index defines the record days, the percent above the 200-day average is ranked, and the equal-weight drawdown and the new-highs count describe the same record day from two other sides: how far the average member sits below its own recent high, and how many members made a new high with the index. A staleness check on every breadth source keeps sparse or interrupted data from entering the ranking.


█ NOTES / LIMITATIONS

 • The script runs only on the 1D timeframe and raises a runtime error elsewhere.
 • It does not count index members in bear markets. The percent above the 200-day average is an index-level proxy for member weakness and can disagree with member-level drawdown counts.
 • Ranks are na until the minimum number of earlier ranked readings exists after the ranking history start. On SP:SPX with default settings, the breadth rank first appears in December 2013 and the equal-weight rank in March 2014.
 • Record detection depends on loaded history. Without a seed, the first loaded bar counts as a record and early records are measured against a running maximum that excludes earlier history. The seed covers only SP:SPX or TVC:SPX histories that begin between 2000-03-25 and 2007-05-30. Later starts produce the table warning.
 • The ranking history start fixes the reference set, so ranks do not depend on how much history loads, provided the loaded history reaches back to that date and the running maximum is correct.
 • On the live bar, a record close and all values derived from it can change until the session closes, because the logic uses the current close without waiting for bar confirmation.
 • The equal-weight request uses lookahead only to align that feed's bar timestamps with the index session, as described in HOW IT WORKS. The other requests use no lookahead, and each rank uses only record closes before the current one.
 • The ranking loop runs only on record closes and iterates over every earlier ranked reading, so its cost grows with the number of record closes since the ranking history start.
 • The script classifies record closes. It contains no forecasting logic.

Pernyataan Penyangkalan

Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.