OPEN-SOURCE SCRIPT

TT - SPDR Sector RS vs Benchmark

389
SPDR Sector Relative Strength vs Benchmark

A top-down dashboard that ranks the 11 S&P 500 SPDR sector ETFs by how strongly each is outperforming or underperforming a benchmark (SPY by default) across multiple timeframes — plus a momentum read on which sectors are gaining or losing ground. Built for traders who want to find the strongest sectors first, then hunt individual stock setups inside them.


WHAT IS RELATIVE STRENGTH?

Relative strength (RS) here means a sector's return minus the benchmark's return over the same window. If XLK returns +8% over a month while SPY returns +5%, XLK's RS is +3% — it beat the market by three points. A positive number means the sector is leading; negative means it's lagging. This is more useful than raw return for sector rotation, because it tells you where money is flowing relative to the broad index, not just whether things went up.


HOW TO READ THE TABLE

- 1D / 1W / 1M / 3M / 6M / 1Y — relative strength over each trailing window. Green = beating the benchmark, red = lagging. Each column can be toggled on or off, and the cell colour deepens with the size of the move so you can read the whole grid at a glance.

- Score — the average relative strength across every enabled timeframe, giving you a single ranking number. A sector that's green across all horizons is a more durable leader than one that's only popped on a single window.

- Mom (Momentum) — whether relative strength is improving or deteriorating, by comparing a recent window against an older one. Positive (green) means strength is building; negative (red) means it's fading. This is often where rotation shows up before it's obvious in the raw RS columns.


MOMENTUM MODES

Momentum offers three calculations (Settings > Momentum Mode):

- Level diff — the raw difference between the recent and older RS. Simplest, but biased: a longer window naturally accumulates a bigger number, so it can mislead.

- Pace (per-bar) — rescales the older window to the recent window's length before comparing, removing that size bias.

- Pace (non-overlap) — compares the most recent stretch against the separate, earlier stretch before it. This is a true acceleration measure and the best early signal of a sector quietly turning up or rolling over. It's the default.

Tip: a sector showing a shrinking negative in the raw columns isn't necessarily recovering — shorter windows always show smaller cumulative numbers. The pace modes correct for this and reveal whether the sector is actually decelerating or still getting worse, faster.


KEY SETTINGS

- Benchmark — what each sector is measured against. Swap SPY for QQQ, IWM, or any symbol.
- Measurement Timeframe — the bar size lookbacks are counted in. Daily is recommended, where 5 bars ≈ 1 week, 21 ≈ 1 month, 63 ≈ 3 months, 126 ≈ 6 months, 252 ≈ 1 year.
- RS Columns Show — Cumulative (total RS per window) or Per-Month Rate (RS divided by the months in each window) for an apples-to-apples monthly pace across columns.
- Gradient Scale — Auto (each column scaled to its own strongest sector) or Manual (a fixed percentage maps to the deepest colour, so every column shares one scale).
- Plus full control of table position, size, font, colours and which columns are shown.


A SUGGESTED WORKFLOW

1. Sort by Score (or Momentum) descending.
2. Favour sectors that are both strong (high Score) AND strengthening (positive Momentum) — that combination tends to flag leadership early rather than late.
3. Drill into the top one or two sectors and look for individual stock candidates there. Skip the laggards.
4. For shorter holds, lean on the 1W / 1M columns and momentum; for swing positions, weight the 3M / 6M horizons.


NOTES

- When a column is set to a higher timeframe than your chart, its value updates until that higher-timeframe bar closes. This is expected behaviour, not repainting of confirmed bars.
- In Per-Month Rate mode the 1D and 1W columns get extrapolated to a full month and will look large and noisy — untick them and lean on the 1M–1Y columns in that mode.
- Sector weights are deliberately not used; index weighting tells you what moves SPY, not where the best opportunities are.

This script is an analysis and educational tool, not financial advice. Relative strength is backward-looking and can reverse quickly. Always do your own research and manage risk.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。