OPEN-SOURCE SCRIPT
Relative Strength Ratio • Leader Shift Signals

## Overview
This indicator computes a **Relative Strength (RS) ratio** between your chart’s symbol and a reference symbol (e.g. BTC or index), then overlays an EMA-based trend filter and detects **RS divergences** via RSI on that ratio. It highlights when your symbol is leading vs lagging, and spots potential turning points via bullish/negative divergences. No alerts are forced, you get visual cues (lines & labels) only.
---
## How It Works
1. **RS Ratio** = (base symbol price) ÷ (reference symbol price).
2. Two EMAs (fast & slow) filter trend context and help identify “leader shifts” (when ratio crosses the fast EMA under trend constraints).
3. **RSI on the ratio** is used to detect divergences. We find swing highs/lows in the *ratio* and compare their RSI values:
* **Bearish RS divergence**: ratio makes a higher high, but RSI makes a lower high
* **Bullish RS divergence**: ratio makes a lower low, but RSI makes a higher low
4. When divergence is confirmed, the script draws connecting lines (and optional markers) on the RS ratio pane to visually flag them.
5. You can customize pivot sensitivity, minimum separation, colors, and toggles for which graphics to show.
---
## Best Usage Suggestions
* Use a **reference symbol** that is meaningfully related (e.g. BTC for altcoins, SPX for equities, or a sector index for a stock). The interpretive power comes from seeing relative strength vs a meaningful peer.
* On **higher timeframes** (4H, daily), divergences tend to carry more weight. On lower intraday charts, tighten pivot settings to avoid noise.
* Prefer divergence signals when the RS ratio is also in a favorable trend (e.g. above its EMA for bullish divergences, below for bearish). Using the trend filter EMAs helps reduce false signals.
* Always confirm divergence signals with **price structure, volume, or other momentum indicators**. Divergence is a warning or a hint—not a standalone trigger.
* Because RSI on ratio is subject to noise, avoid over-tuning pivots too tight; broader pivot widths give more robust divergence lines.
---
## Inputs & Customization
* **Reference Symbol & Timeframe** for ratio comparison
* **Fast EMA / Slow EMA lengths** and slope threshold (trend filter)
* **RSI length** applied to the RS ratio
* **Pivot left / right bars** and **min separation** to define sturdy swings
* **Toggle lines / markers** visibility, and pick colors for divergence, ratio, EMAs
* Optional “shade” or fill modes (if you have them)
---
## Limitations & Disclaimers
* Divergence does **not guarantee** reversals—it often signals **weakening momentum or potential turning zones**, which may not always play out.
* In extremely volatile or fast-moving markets, divergence lines may lag or fail.
* The script relies on historical data (no future lookahead). Because pivots are confirmed after a few bars, some signals show with delay.
* As always: combine with price action, structure, risk management. This is a tool—not a magic eight ball.
---
This indicator computes a **Relative Strength (RS) ratio** between your chart’s symbol and a reference symbol (e.g. BTC or index), then overlays an EMA-based trend filter and detects **RS divergences** via RSI on that ratio. It highlights when your symbol is leading vs lagging, and spots potential turning points via bullish/negative divergences. No alerts are forced, you get visual cues (lines & labels) only.
---
## How It Works
1. **RS Ratio** = (base symbol price) ÷ (reference symbol price).
2. Two EMAs (fast & slow) filter trend context and help identify “leader shifts” (when ratio crosses the fast EMA under trend constraints).
3. **RSI on the ratio** is used to detect divergences. We find swing highs/lows in the *ratio* and compare their RSI values:
* **Bearish RS divergence**: ratio makes a higher high, but RSI makes a lower high
* **Bullish RS divergence**: ratio makes a lower low, but RSI makes a higher low
4. When divergence is confirmed, the script draws connecting lines (and optional markers) on the RS ratio pane to visually flag them.
5. You can customize pivot sensitivity, minimum separation, colors, and toggles for which graphics to show.
---
## Best Usage Suggestions
* Use a **reference symbol** that is meaningfully related (e.g. BTC for altcoins, SPX for equities, or a sector index for a stock). The interpretive power comes from seeing relative strength vs a meaningful peer.
* On **higher timeframes** (4H, daily), divergences tend to carry more weight. On lower intraday charts, tighten pivot settings to avoid noise.
* Prefer divergence signals when the RS ratio is also in a favorable trend (e.g. above its EMA for bullish divergences, below for bearish). Using the trend filter EMAs helps reduce false signals.
* Always confirm divergence signals with **price structure, volume, or other momentum indicators**. Divergence is a warning or a hint—not a standalone trigger.
* Because RSI on ratio is subject to noise, avoid over-tuning pivots too tight; broader pivot widths give more robust divergence lines.
---
## Inputs & Customization
* **Reference Symbol & Timeframe** for ratio comparison
* **Fast EMA / Slow EMA lengths** and slope threshold (trend filter)
* **RSI length** applied to the RS ratio
* **Pivot left / right bars** and **min separation** to define sturdy swings
* **Toggle lines / markers** visibility, and pick colors for divergence, ratio, EMAs
* Optional “shade” or fill modes (if you have them)
---
## Limitations & Disclaimers
* Divergence does **not guarantee** reversals—it often signals **weakening momentum or potential turning zones**, which may not always play out.
* In extremely volatile or fast-moving markets, divergence lines may lag or fail.
* The script relies on historical data (no future lookahead). Because pivots are confirmed after a few bars, some signals show with delay.
* As always: combine with price action, structure, risk management. This is a tool—not a magic eight ball.
---
오픈 소스 스크립트
진정한 트레이딩뷰 정신에 따라 이 스크립트 작성자는 트레이더가 기능을 검토하고 검증할 수 있도록 오픈소스로 공개했습니다. 작성자에게 찬사를 보냅니다! 무료로 사용할 수 있지만 코드를 다시 게시할 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.
오픈 소스 스크립트
진정한 트레이딩뷰 정신에 따라 이 스크립트 작성자는 트레이더가 기능을 검토하고 검증할 수 있도록 오픈소스로 공개했습니다. 작성자에게 찬사를 보냅니다! 무료로 사용할 수 있지만 코드를 다시 게시할 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.