Sector Relative Strength

This script compares sector performance relative to the S&P 500. Sector price levels or charts alone can mislead, because they tend to move with the broader market. An increase in a sector’s price does not always indicate strength, as it may simply be following the index.

For more a more reliable picture, the script calculates a ratio between each sector ETF and SPY. If the ratio has increased, the sector has outperformed the index. In case it has declined, the sector has underperformed. If the value is near zero, the sector has moved in line with the index. The sectors are presented in a table and sorted on relative performance.

▸ TradingView Link

Calculation Method
The performance is expressed as a percentage change in the ratio of each sector ETF to SPY over a user-defined lookback period.

Relative % = [(Sector / SPY) now ÷ (Sector / SPY) lookback − 1] × 100

The default lookback is set to 1 Month and can be selected from a menu with predefined options: 1 Day, 1 Week, 1 Month, 3 Months, 6 Months, and 1 Year.

Table Columns
Relative %: The sector’s performance relative to SPY over the selected lookback period.
Trend Arrow: Indicates the direction of relative performance up down or flat.

Example Interpretation
The table provides a simple view of relative performance. For example, if XLK shows a +7.16% change, it means the technology sector has outperformed SPY over the selected lookback period, while XLB, showing –3.98%, indicates underperformance relative to the index. Positive values reflect relative strength, and negative values indicate weakness.

Use Case
This approach helps evaluate overall market conditions and supports a top-down method. By starting with sector performance, it becomes easier to identify where the market is showing leadership or weakness. This allows the stock selection process to be more deliberate and can help refine or customize screeners based on certain sectors.