OPEN-SOURCE SCRIPT

RS Leader vs Benchmark

246
RS Leader vs Benchmark

1. Overview


RS Leader vs Benchmark is a relative strength analysis indicator designed to compare the current chart symbol against a selected benchmark.

The indicator calculates a relative strength line using:

Symbol Close / Benchmark Close

When the RS line rises, the chart symbol is outperforming the selected benchmark.

When the RS line falls, the chart symbol is lagging the selected benchmark.

This tool is designed as a market leadership and watchlist filtering indicator. It is not a trading strategy. It does not place trades, does not execute orders, and does not produce TradingView Strategy Tester results.

2. Purpose

The main purpose of this indicator is to help traders answer a simple question:

Is this symbol stronger or weaker than its benchmark?

This can be useful before applying other trading methods such as trend-following, breakout, pullback, or market structure analysis.

The indicator helps users identify symbols that are showing relative strength compared with a selected market, sector, crypto benchmark, forex benchmark, or custom reference symbol.

3. Relative Strength Line

The main RS line is calculated by dividing the chart symbol by the selected benchmark.

If the RS line is rising, the symbol is outperforming the benchmark.

If the RS line is falling, the symbol is underperforming or lagging the benchmark.

This allows users to study performance relative to a reference market rather than looking only at the symbol's own price movement.

4. RS EMA

ảnh chụp nhanh

The script plots an EMA of the RS line.

This EMA acts as a relative strength trend reference.

When RS is above its EMA, the symbol is considered to be outperforming its own relative strength trend.

When RS is below its EMA, the symbol is considered to be lagging its own relative strength trend.

The default RS EMA length is 50.

Users can adjust this value depending on their timeframe and analysis style.

5. RS Momentum

The indicator calculates RS Momentum as the percentage change of the RS line over a selected lookback period.

The default momentum lookback is 63 bars.

On a daily chart, 63 bars is approximately three trading months.

Positive RS Momentum means the symbol's relative strength is improving.

Negative RS Momentum means the symbol's relative strength is weakening.

6. RS Rating

The script includes an RS Rating from 0 to 100.

This rating is calculated using the percentile rank of the current RS value within the symbol's own RS history.

A higher value means the current RS is strong compared with its own historical RS range.

A lower value means the current RS is weak compared with its own historical RS range.

Important note:

This RS Rating is a single-symbol historical percentile. It is not a full cross-sectional market ranking across all stocks or assets.

7. RS Leader State

The indicator defines an RS Leader state when the following conditions are met:

* RS is above its RS EMA
* RS Momentum is positive
* Optional RS Rating filter is satisfied, if enabled

When these conditions are met, the symbol is classified as an RS Leader relative to the selected benchmark.

When the conditions are not met, the symbol is classified as Not Leader.

This state is intended for watchlist filtering and relative strength review. It should not be treated as a direct buy or sell signal.

8. Optional RS Rating Filter

The script includes an optional RS Rating filter.

When enabled, the RS Leader state also requires the RS Rating to be above the selected minimum value.

For example, if the minimum rating is set to 60, the symbol must have:

* RS above RS EMA
* Positive RS Momentum
* RS Rating of 60 or higher

This gives users a stricter leadership filter.

9. Benchmark Mode

The script includes three benchmark modes:

* Auto Benchmark
* Benchmark Preset
* Custom Benchmark

This design makes the indicator easier for users who may not know which benchmark to select.

10. Auto Benchmark

Auto Benchmark attempts to select a benchmark based on the current symbol type.

Examples:

* US stocks and US funds use SPY as the automatic broad-market benchmark.
* Crypto symbols use BTCUSDT as the automatic crypto benchmark.
* BTC itself uses the total crypto market benchmark.
* Forex symbols use DXY as the automatic dollar-index benchmark.
* Unknown or unsupported cases fall back to the custom benchmark field.

Auto Benchmark is intended to help users get started quickly.

Because there is no single perfect benchmark for every market, users can still switch to Preset or Custom mode when needed.

11. Benchmark Preset

Benchmark Preset allows users to select from a ready-made list.

Available presets include:

* US Broad Market - SPY
* US Tech - QQQ
* US Small Caps - IWM
* Crypto vs Bitcoin - BTCUSDT
* Crypto vs Ethereum - ETHUSDT
* Crypto Total Market - TOTAL
* Forex vs Dollar Index - DXY
* Custom Benchmark

This is useful for users who want a guided benchmark selection without manually typing symbols.

12. Fallback / Custom Benchmark

The Fallback / Custom Benchmark field allows users to manually select any benchmark symbol.

This is especially useful for:

* Local stock markets
* Country-specific indices
* Sector indices
* ETFs
* Futures markets
* Custom relative strength comparisons
* Special benchmark studies

In Auto Benchmark mode, this field is used only when the script cannot reliably assign an automatic benchmark.

The field remains visible in the settings because TradingView Pine inputs cannot be dynamically hidden.

13. Badge Table

The indicator includes an optional badge table.

The badge displays:

* RS Status
* Benchmark mode
* Active benchmark
* Reason for benchmark selection
* Trend state
* RS Momentum
* RS Rating
* State rule
* Use context

The table helps users understand which benchmark is being used and why.

14. Badge Size

The badge table includes multiple text-size options:

* Tiny
* Small
* Normal
* Large

This allows users to adjust the table for different screen sizes, chart layouts, and visual preferences.

15. Background Tint

The script can display a background tint.

A green tint appears when the symbol is in RS Leader state.

A red tint can appear when the symbol is lagging its RS trend.

This visual layer is optional and can be turned on or off in the settings.

16. Alerts

The script includes alert conditions for:

* RS crossing above its EMA
* RS crossing below its EMA
* RS Leader state turning ON
* RS Leader state turning OFF

Alerts are notifications only. They do not place trades and do not confirm broker execution.

17. How to Use

A practical workflow:

1. Add the indicator to a chart.

2. Leave Benchmark Mode on Auto Benchmark for general use.

3. Use Benchmark Preset if you want to choose a guided benchmark.

4. Use Custom Benchmark for local markets or special comparisons.

5. Watch the RS line relative to the RS EMA.

6. Look for symbols where RS is above its EMA.

7. Review RS Momentum to see if leadership is improving.

8. Review RS Rating to understand where current RS stands compared with its own history.

9. Use RS Leader state as a watchlist filter, not as a direct trade entry signal.

10. Combine the indicator with trend, market structure, volume, support/resistance, and risk management.

11. Suggested Use Cases

RS Leader vs Benchmark can be useful for:

* Watchlist filtering
* Market leadership analysis
* Relative strength review
* Sector or benchmark comparison
* Crypto strength comparison
* Forex benchmark comparison
* Stock selection
* Trend-following preparation
* Breakout candidate filtering
* Comparing symbols against a broad market, sector, or custom reference

19. Important Limitations

This indicator does not predict future price movement.

It does not guarantee outperformance.

It does not guarantee profitable trades.

It is not a trading strategy.

It does not place orders.

It does not provide buy or sell recommendations.

RS Leader state is a relative strength condition, not a trade signal.

A symbol can show relative strength and still decline in price if the entire market is falling.

A symbol can lag its benchmark and still move upward if the benchmark is stronger.

Benchmark selection affects the result significantly.

Auto Benchmark is a helpful starting point, but it may not always select the best benchmark for every symbol or market.

Users should select an appropriate benchmark for their market, asset class, and analysis objective.

20. Originality and Purpose

RS Leader vs Benchmark combines relative strength ratio analysis with trend, momentum, rating, benchmark presets, automatic benchmark selection, and a visual leader-state table.

The script is designed to make relative strength analysis easier for users who may not know which benchmark to choose.

The main purpose is to provide a clear and practical market leadership filter for chart analysis and watchlist review.

21. Educational Disclaimer

This script is for educational and chart-analysis purposes only. It is not financial advice, investment advice, or a recommendation to buy or sell any financial instrument. Users should perform their own analysis and manage risk independently.

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.