PROTECTED SOURCE SCRIPT
RRG Style RS & Momentum (vs Benchmark) by AKM

## What this indicator does
This indicator is an **RRG‑style Relative Strength & Momentum tool**.
It compares the current symbol to a chosen benchmark (e.g. NIFTY / NIFTY 500) and plots:
- **RS‑Ratio**: Out/under‑performance of the symbol vs the benchmark, normalized around 100.
- **RS‑Momentum**: Momentum of that relative strength, also normalized around 100.
- **RS‑Signal**: A smoothed signal line of RS‑Ratio (EMA of RS‑Ratio).[1][2]
Using these two axes (RS‑Ratio and RS‑Momentum), each bar is classified into one of four **RRG‑style quadrants**:
- **LEADING** – RS‑Ratio > 100 and RS‑Momentum > 100
- **WEAKENING** – RS‑Ratio > 100 and RS‑Momentum < 100
- **LAGGING** – RS‑Ratio < 100 and RS‑Momentum < 100
- **IMPROVING** – RS‑Ratio < 100 and RS‑Momentum > 100[3][1]
The chart background is color‑coded by quadrant, and a label on the center (100) line shows the current zone name (LEADING / WEAKENING / LAGGING / IMPROVING) in real time.
> **Concept credit:**
> The conceptual framework of “Relative Strength vs Momentum” in four quadrants (Leading, Weakening, Lagging, Improving) is inspired by **Relative Rotation Graphs® (RRG®)**, created by **Julius de Kempenaer** and commercialized through RRG Research and platforms like Bloomberg, StockCharts, Optuma, etc.[4][5][6]
> This script is only an RRG‑inspired *1‑symbol vs benchmark* implementation inside Pine, not an official RRG product.
***
## Inputs
- **Benchmark symbol**:
Default `NSE:NIFTY`. You can set `NSE:NIFTY500`, `NSE:BANKNIFTY`, sector indices, etc.
- **RS base length (`rsLen`)**:
EMA length for smoothing the raw price ratio (symbol / benchmark). Lower = more sensitive, higher = smoother.
- **Smoothing length (`smoothLen`)**:
Secondary smoothing for RS‑Ratio. Default 14.
- **Signal length (`signalLen`)**:
EMA length for the RS‑Signal line (EMA of RS‑Ratio).
- **Momentum length (`momLen`)**:
Lookback for optional ROC‑based momentum.
- **Use ROC‑based momentum**:
If `false` (default): RS‑Momentum is computed as RS‑Ratio / EMA(RS‑Ratio) × 100 (ratio‑style).
If `true`: RS‑Momentum uses ROC(RS‑Ratio, momLen) + 100 (ROC‑style).[7][8]
- **Show quadrant background**:
Toggles colored background by quadrant.
- **Show zone name on background**:
Shows a label on the 100‑line with the current quadrant name.
***
## How to read it
There is a horizontal center line at **100**:
- **RS‑Ratio > 100** → symbol is outperforming the benchmark.
- **RS‑Ratio < 100** → symbol is underperforming the benchmark.
- **RS‑Momentum > 100** → relative strength is improving (momentum picking up).
- **RS‑Momentum < 100** → relative strength is fading.[9][1]
The four zones behave similar to classic RRG quadrants:
- **LEADING (lime/green background)**
- RS‑Ratio > 100 and RS‑Momentum > 100.
- Symbol is **stronger than the benchmark and momentum is strong**.
- This is where leadership typically resides.
- **WEAKENING (orange background)**
- RS‑Ratio > 100 and RS‑Momentum < 100.
- Still outperforming, but momentum is rolling over.
- Late‑stage leadership / time to be more selective and manage exits.
- **LAGGING (red background)**
- RS‑Ratio < 100 and RS‑Momentum < 100.
- Underperforming with weak momentum.
- Worst zone for aggressive longs.
- **IMPROVING (green background)**
- RS‑Ratio < 100 and RS‑Momentum > 100.
- Still weaker than benchmark, but momentum is improving.
- Early turnaround zone where future leaders often start.[1][3]
The **white RS‑Signal line** is just a smoother of RS‑Ratio, helpful to visually see RS trend and crossovers.
***
## Practical trading use (RRG‑style workflow)
This indicator is designed as a **selection and context filter**, not a stand‑alone entry/exit system.
### 1. Sector and stock selection
1. Apply it to **sector indices** vs a broad benchmark (e.g., Nifty IT vs NIFTY 500, Nifty Auto vs NIFTY 500).
2. Focus on sectors where:
- The zone label is **IMPROVING → LEADING** over recent bars.
- RS‑Ratio is rising and staying above 100 in LEADING.
3. Then, on individual stocks inside those strong sectors, use the same benchmark and indicator:
- Prefer stocks that are also in **LEADING** (or just moved from **IMPROVING** into **LEADING**).
This recreates the essence of using RRG to find sectors/stocks with strong relative strength and momentum.[6][10]
### 2. Combining with your price setup
Once a stock/sector passes the RS filter:
- Use your own price‑action / indicator rules for entries (EMA trends, VWAP pullbacks, breakouts, etc.).
- Example for longs:
- Only take long setups when:
- Sector index AND stock are in **LEADING** or newly from **IMPROVING → LEADING**, and
- Price is in an uptrend on your main chart (e.g., above 20/50 EMA, higher highs and higher lows).
### 3. Managing exits and rotation
- When a held symbol shifts from **LEADING → WEAKENING → LAGGING** and RS‑Momentum stays < 100, consider:
- Tightening stops.
- Partially booking profits.
- Rotating into other names still in LEADING / IMPROVING.
This mirrors how many investors use “sector rotation” and RRG to stay in stronger groups and reduce exposure in weakening ones.[11][12]
***
## Disclaimers
- This script is for **educational and analytical purposes only** and is **not financial advice or a recommendation** to buy/sell any security.
- **Relative Rotation Graphs® / RRG®** and the four‑quadrant concept belong to **Julius de Kempenaer and RRG Research**; this Pine implementation is an independent, simplified adaptation for one symbol vs a benchmark and is **not an official RRG product or library**.
สคริปต์ที่ได้รับการป้องกัน
สคริปต์นี้ถูกเผยแพร่เป็นแบบ closed-source อย่างไรก็ตาม คุณสามารถใช้ได้อย่างอิสระและไม่มีข้อจำกัดใดๆ – เรียนรู้เพิ่มเติมได้ที่นี่
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์ที่ได้รับการป้องกัน
สคริปต์นี้ถูกเผยแพร่เป็นแบบ closed-source อย่างไรก็ตาม คุณสามารถใช้ได้อย่างอิสระและไม่มีข้อจำกัดใดๆ – เรียนรู้เพิ่มเติมได้ที่นี่
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน