TV Script - Trading Dashboard Documentation

Comprehensive documentation for TradingView Pine Script indicators and trading strategies

View the Project on GitHub tekram/tv-script

RS Rating / RS Line System

Overview

The RS Rating system calculates a stock’s relative strength performance compared to the S&P 500 over the past 12 months, providing a 1-99 rating similar to IBD’s RS Rating. The RS Line visually displays the stock’s relative performance vs. the market.

Credit: © Fred6724, RaviYendru (initial script)

RS Rating (1-99 Scale)

How It Works

  1. Performance Calculation: Calculates stock and SPX performance over 4 quarters (63, 126, 189, 252 days)
  2. Weighted Average: Last quarter weighted 40%, others 20% each
  3. Relative Score: Compares stock performance to SPX performance
  4. Percentile Assignment: Maps score to 1-99 percentile using market-wide calibration

Rating Interpretation

Calculation Formula

// Stock performance (weighted)
rs_stock = 0.4 * perfTicker63 + 0.2 * perfTicker126 + 
           0.2 * perfTicker189 + 0.2 * perfTicker252

// SPX performance (weighted)
rs_ref = 0.4 * perfComp63 + 0.2 * perfComp126 + 
         0.2 * perfComp189 + 0.2 * perfComp252

// Relative score
totalRsScore = rs_stock / rs_ref * 100

RS Line

Visual Display

RS Line Features

RS New Highs / New Lows

Blue Dots (RS New Highs)

Red Dots (RS New Lows)

MA Overlays on RS Line

1st MA on RS Line

2nd MA on RS Line

Percentile Calibration

Market-Wide Calibration

Replay Mode

Configuration Options

RS Line Settings

RS New Highs/Lows

MA Settings

Trading Applications

Stock Selection

Entry Timing

Risk Management

Best Practices

  1. Focus on High RS: Only trade stocks with RS Rating > 70
  2. Watch RS New Highs: Blue dots often precede price moves
  3. RS Line Trend: Rising RS Line = favorable
  4. Combine with Structure: High RS + pullback to structure = best setups
  5. Monitor Declines: RS Rating drops = reduce exposure

Technical Details

Percentile Assignment

The system uses a complex percentile mapping function that:

Data Sources