OPEN-SOURCE SCRIPT

Composite Valuation Standard Score

451
█ OVERVIEW

Composite Valuation Standard Score (CVSS) plots a single 0 to 100 line that measures how expensive the broad US equity market is against its own entire recorded history, by combining up to six valuation ratios through point-in-time statistics. The thesis: one valuation metric can mislead in isolation, but the average anchored z-score of several independent lenses (earnings, cyclically adjusted earnings, book value, sales, output, replacement cost) gives a robust reading of how uniformly stretched or depressed valuations are, without using any future data at any bar.


█ HISTORY / BACKGROUND

Averaging the historical percentile of many valuation ratios into one composite is a long-standing practice in institutional market research. The individual components carry their own lineage: the cyclically adjusted price to earnings ratio was developed by Robert Shiller, the market capitalization to GDP ratio is widely associated with Warren Buffett, and the ratio of corporate equity value to corporate net worth descends from James Tobin's Q. The specific construction used here, an expanding winsorized z-score per component with a minimum-history admission gate and a composite-level percentile mapping, is a novel method built for this script. Its conceptual basis is that every observation should be judged only against the history that existed when it printed, and that a metric making new all-time highs should keep conveying magnitude instead of freezing at the top of a percentile scale.


█ HOW IT WORKS

All series are sampled once per calendar month through request.security at the 1M timeframe with lookahead off. Two of the six components are ratios computed from a numerator and denominator symbol: Market Cap / GDP (a total market index divided by nominal GDP) and the Q Ratio proxy (nonfinancial corporate equities at market value divided by nonfinancial corporate net worth). Because every series is immediately transformed to ranks and z-scores, absolute units and level calibration are irrelevant; only the shape of each series matters.

The algorithm, step by step:

1. On each new monthly bar, each enabled component's value is inserted into that component's
sorted history array. The arrays only ever grow; nothing is discarded.
2. A component becomes "live" once its array holds at least the minimum-history gate
(default 120 monthly observations). Before that it accumulates data but does not
contribute, which prevents thin early samples from producing meaningless statistics.
3. Each live component's current value is converted to an anchored z-score against the
expanding mean and standard deviation of its own array, then winsorized by clamping
to plus or minus 3 (adjustable).
4. The composite z is the equal-weight average of all live winsorized z-scores, computed
whenever at least the minimum number of components (default 2) is live.
5. The composite z is itself inserted into an expanding array and converted to its own
expanding percentile rank. That rank is the 0 to 100 headline line.
6. Separately, each live component's expanding percentile rank is compared with the
extreme threshold (default 90). The share of live components above the threshold
is plotted as the extremes-breadth columns.

An optional Excess CAPE Yield series (100 divided by CAPE, minus the 10-year Treasury yield) can be plotted and is always available in the table when enabled.


█ HOW TO USE

Apply the script on a Monthly chart of a symbol with deep monthly history. The chart symbol only supplies the time axis; the valuation data comes from the configured feeds. Charting the trailing P/E series itself, or a long-history index, exposes the full record back to the late 19th century. On a short-history chart symbol the statistics rank against a short window and the reading is not comparable.

Reading the pane is simple:

• The teal line is the market's expensiveness rank from 0 to 100. A reading of 96 means
the current composite valuation is richer than 96 percent of everything that came
before it. A reading of 5 means cheaper than 95 percent of prior history.
• Above the dotted 90 line with a red background: valuations are in their most expensive
historical decile. Below the dotted 10 line with a green background: cheapest decile.
• The orange columns show agreement. At 100, every live metric is simultaneously in its
own extreme zone; at 0, none is. High teal with low orange means the composite is
stretched but the stretch is concentrated in few metrics.
• The table in the top right shows each component's status (off, gated with progress,
or live), its current percentile, and its z-score, plus the composite row and the
Excess CAPE Yield row.

This is a slow macro positioning gauge, not a timing signal. Elevated readings can persist for years. Its practical use is context: sizing long-term risk, framing regime, and flagging when many independent valuation lenses agree at an extreme.


█ SETTINGS

• Components group: six on/off toggles, each with editable symbol fields. Trailing P/E
(default on), Shiller CAPE (default on), Price / Book (default on), Price / Sales
(default on), Market Cap / GDP with numerator and denominator symbols (default on),
Q Ratio proxy with numerator and denominator symbols (default on).
• Minimum-history gate: monthly observations a component needs before it contributes.
Default 120.
• Winsorize z at +/-: clamp magnitude for component z-scores. Default 3.
• Minimum live components: fewest live components required for the composite to plot.
Default 2.
• Extreme threshold (percentile): level defining the expensive zone for the background,
and the per-component extreme used by the breadth columns. Default 90.
• Cheap threshold (percentile): level defining the cheap zone for the background.
Default 10.
• Plot Excess CAPE Yield: adds the ECY series in percent to the pane and status line.
Default off. Its 10-year yield symbol is editable.
• Show component table: toggles the status table. Default on.


█ WHAT MAKES IT ORIGINAL

Published valuation scripts overwhelmingly track a single ratio, and existing multi-series composites in other domains rank each input over a fixed rolling window or against full-sample statistics. This script differs in four specific, verifiable ways. First, every statistic is point-in-time: each bar is ranked and scored only against observations that existed at that bar, so no early reading benefits from data that had not yet occurred. Second, the primary transform is a winsorized anchored z-score rather than a percentile, so a component that breaks above all prior history continues to register increasing magnitude up to the clamp instead of pinning at 100 and going silent. Third, a minimum-history admission gate handles the unequal start dates of the underlying feeds explicitly: short-history components accumulate until they are statistically meaningful, and the effective composition of the composite changes transparently over time, disclosed live in the table. Fourth, the extremes-breadth columns quantify cross-metric agreement, separating a composite driven by one distorted ratio from one where independent valuation lenses are stretched simultaneously.


█ NOTES / LIMITATIONS

• Sample depth is bounded by the chart symbol's bar history, because expanding statistics
can only accumulate on bars that exist on the chart. Use a deep-history monthly chart.
• The effective component set varies by era. Only the two earnings-based series reach the
19th century; book value and sales feeds begin near 2000, and the market cap and Q feeds
clear the gate later still. Early readings are a two-component composite. The table
always shows which components are live.
• Components whose feeds return no data stay gated and are excluded; the composite
requires the configured minimum of live components or it plots na.
• The value on the developing monthly bar updates until that bar closes. On timeframes
below monthly the current month's reading evolves intraperiod. No lookahead is used
and completed bars do not repaint from the script's side.
• The underlying economic feeds are revised at the source. National accounts and flow of
funds series can be restated historically, which changes past values of the affected
components when the data provider updates them.
• Quarterly feeds repeat their value across the months of a quarter, which mildly smooths
the expanding distributions.
• This indicator describes valuation rank relative to history. It makes no claim about
future returns or the timing of any reversal.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.