OPEN-SOURCE SCRIPT

Cyclical Peak Macro Composite

271
OVERVIEW

Cyclical Peak Macro Composite is a macro and valuation signal panel that tracks a set of independent conditions historically associated with late-cycle equity market peaks and reports the share of them that are currently active. It plots in a separate pane as a single column series, % Triggered, the percent of counting signals that meet their trigger condition, alongside a status table that summarizes each individual signal.

In one sentence: when a majority of independent macro, credit, and valuation conditions seen near prior market peaks are simultaneously active, the late-cycle environment is more elevated than when few of them are.


HISTORY / BACKGROUND

The practice of monitoring a fixed panel of macro, valuation, credit, and sentiment signposts for equity market peaks comes from sell-side equity strategy research, which publishes periodic checklists scoring how many of a set of conditions are active relative to prior peaks. This script implements only the subset of such a checklist whose inputs exist as data on TradingView, substitutes documented proxies where the original series are proprietary, and omits the signals that have no public feed and no faithful proxy rather than approximating them with unrelated data.

The component methods have established lineage:

Term spread. The difference between a long and a short Treasury yield is a standard cycle reference. A negative 10Y minus 2Y spread, an inverted curve, has been present ahead of prior downturns.
Rule of 20. A long standing market heuristic that sums the trailing price to earnings ratio and the year over year inflation rate, treating a value near 20 as a fair value reference and higher readings as richer valuation.
High yield option adjusted spread. The ICE BofA US High Yield index OAS, distributed through FRED, is a widely used gauge of credit risk pricing. Unusually tight spreads are read here as complacency, not stress.
Senior Loan Officer Opinion Survey (SLOOS). The Federal Reserve survey of bank lending standards. A positive net reading indicates tightening credit availability.
Consumer sentiment. The University of Michigan survey, used as an optional proxy for a different consumer confidence series in the original checklist.

The conceptual basis is that these conditions tend to cluster near cyclical peaks, so counting how many are active gives a coarse read on where the cycle sits. The specific composite arrangement is third party research; this script is an independent reconstruction of its available subset.


HOW IT WORKS

The script reads external macro series through request.security and does not use the chart symbol's price in any calculation, so its output is identical on any chart and depends only on the chart timeframe. Every lookback is specified in months and converted to a bar count for the active resolution by round(months times seconds per month divided by seconds per bar), clamped between 1 and 5000 bars, so each window holds its intended calendar duration across resolutions.

It evaluates up to six signals:

Yield curve inversion. Requests the 10Y and 2Y yield symbols at the chart timeframe and takes their spread. Active if the spread was below zero at any point within the latch window, tested with a rolling maximum of the inverted condition.
Credit complacency. Requests the high yield OAS series. Active if the spread was below the tight spread threshold at any point within the latch window. The direction is deliberate: a low spread is the peak signal.
Rule of 20. Computes the year over year change of monthly CPI and adds it to a trailing P/E value, which is a manual input by default or a symbol sourced value if enabled. It then takes a rolling z-score of that sum over the z-score lookback and is active when the z-score exceeds its trigger.
Value versus growth. Requests a value proxy and a growth proxy at the chart timeframe and computes the difference of their returns over the return window, in percentage points. Active when the value proxy trails the growth proxy by more than the underperformance trigger.
SLOOS net tightening. Requests the SLOOS series at a quarterly resolution. Active when the net reading is above zero. Counts only when included and when its data resolves.
Consumer sentiment (optional). Takes a rolling z-score of the sentiment series over the z-score lookback and is active when it exceeds the sentiment trigger. Counts only when enabled and when its data resolves.

The denominator is dynamic. Four core signals always count, plus SLOOS when active, plus sentiment when active. % Triggered is 100 times the number of active triggers divided by the number of counting signals. Any series whose data does not resolve returns na and is excluded from both numerator and denominator rather than scored as off.


HOW TO USE

Add the script to any chart. The chart symbol is irrelevant because all inputs are requested macro series. Read the column height as the percent of counting signals currently triggered. The dashed line marks the composite alert threshold and the dotted line marks the 50 percent midline. The column is gray below 50, orange at or above 50, and red at or above the alert threshold.

The status table in the top right lists each signal with a state of ON, off, or n/a. ON is shown in red because in this context an active signal is a late-cycle condition rather than a healthy one, off is green, and n/a means the signal is disabled or its data did not resolve and it is not counting. The header cell repeats the current percent.

Recommended timeframe: the script is built for the daily resolution and higher, and is cleanest on monthly. CPI, SLOOS, and sentiment are requested at monthly or quarterly resolution and mapped onto the chart's bars, so on a monthly chart one bar corresponds to one source observation and the z-score statistics are exact. On intraday resolutions the month to bar conversion saturates at the 5000 bar clamp and the windows no longer span the intended number of months, so intraday use is not advised.

The diagnostic series, namely the spread, the OAS, the Rule of 20 level and z-score, the SLOOS reading, the value minus growth return, and the sentiment z-score, are not drawn on the pane. They are available in the Data Window for inspection.


SETTINGS

Yield Curve
• 10Y yield symbol: long rate symbol for the term spread. Default US10Y.
• 2Y yield symbol: short rate symbol. Default US02Y.

Credit (HY OAS complacency)
• HY OAS symbol: the high yield option adjusted spread series. Default FRED:BAMLH0A0HYM2.
• Tight spread threshold (%): the level below which the spread is treated as complacent. Default 3.5.

Rule of 20 (P/E + CPI YoY)
• Trailing S&P 500 P/E: the manual trailing P/E used when the symbol feed is off. Default 22.
• Feed P/E from a symbol: when on, sources the P/E from a symbol instead of the manual value. Default off.
• P/E symbol (trailing): the symbol used when the feed is enabled. Default SP:SPX.
• Z-score lookback (months): the window for the Rule of 20 and sentiment z-scores. Default 120, minimum 12.
• Z-score trigger (>): the Rule of 20 z-score level that activates the signal. Default 1.

Value / Growth (low-PE vs high-PE proxy)
• Value proxy symbol: the value style proxy. Default AMEX:SPYV.
• Growth proxy symbol: the growth style proxy. Default AMEX:SPYG.
• Return window (months): lookback for the relative return. Default 6, minimum 1.
• Underperformance trigger (pp): how far the value proxy must trail the growth proxy to activate. Default 2.5.

SLOOS (bank lending)
• Include SLOOS: whether the SLOOS signal counts. Default on.
• SLOOS net tightening symbol: the lending standards series. Default FRED:DRTSCILM.

Consumer sentiment (optional, low fidelity)
• Include sentiment proxy: whether the sentiment signal counts. Default off.
• Sentiment symbol: the sentiment series. Default FRED:UMCSENT.
• Sentiment z-score trigger (>): the z-score level that activates the signal. Default 1.

Composite
• Latch window for prior signals (months): the lookback over which the yield curve and credit signals count as active if their condition occurred at any point inside it. Default 6, minimum 1.
• Composite alert threshold (%): the percent at which the alert condition and red coloring engage. Default 70.


WHAT MAKES IT ORIGINAL

This is not a wrapper around other indicators and reuses no third party signal code. It computes each condition directly from primary macro and valuation series and combines them with three specific design choices:

Honest scope. It implements only the checklist signals that have real TradingView data, omits the proprietary and unavailable ones outright, and labels the two proxies it uses as proxies. The value and growth style spread stands in for a low P/E versus high P/E basket, and the optional University of Michigan z-score stands in for a different consumer confidence index. The percent reading is therefore not comparable to the source checklist's percent, which is computed over a larger set of signals.
Deliberate credit direction. The credit signal fires on tight spreads, not wide ones, because the underlying idea is complacency near a peak rather than stress. This inverts the intuitive reading and is stated rather than hidden.
Calendar anchored windows and graceful degradation. Every lookback is expressed in months and converted to bars for the current resolution, so latch and z-score windows keep their duration across timeframes, and any series that fails to resolve drops out of the denominator instead of being scored as off.


NOTES / LIMITATIONS

Symbol independent. The composite ignores the chart symbol entirely. Every input is requested through request.security, so changing the chart instrument does not change the output. Only the chart timeframe matters.
Timeframe sensitivity. Built for daily and higher, best on monthly. On intraday resolutions the month to bar conversion is clamped at 5000 bars and the windows no longer span the intended months, so the latch and z-score logic are not valid intraday.
Data availability. The macro series depend on TradingView's data catalog and on your data access. SLOOS is quarterly, heavily lagged, and may not resolve in the FRED catalog. The OAS, CPI, and sentiment series are likewise subject to availability. Unresolved series return na and are excluded. The value and growth proxy symbols use an exchange prefix that may need changing to match your data.
Insufficient history. The z-scores require their full lookback of observations before they return a value. Until then the Rule of 20 and sentiment signals are na and do not count. The value versus growth signal requires history at least as long as its return window on both proxies, otherwise it returns na.
Economic data revisions. CPI, SLOOS, and sentiment are released with a lag and can be revised, so the most recent readings may change as the source updates. No bar level lookahead is used. The requests run with default settings and the latch references only historical values.
Static manual P/E. If the trailing P/E is left as a manual constant, the Rule of 20 z-score reduces to a z-score of inflation plus a constant, since the only varying term is CPI. Enabling a symbol sourced trailing P/E restores the intended behavior.
Correlated signals. These macro and valuation conditions tend to move together late in a cycle, so the percent reading reflects fewer independent pieces of information than the raw signal count suggests.

Отказ от ответственности

Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.