PROTECTED SOURCE SCRIPT

IBD Style RS Rating Line Indicator

66
Purpose

  • Measures relative performance, not just price action.
  • Recreates the IBD-style 1–99 RS Rating inside TradingView.


RS Line

  • Plots stock price relative to a benchmark (default: SPX).
  • Scaled for readability; supports indices and sectors.
  • Optional MA overlays and positive/negative fill zones.


RS New Highs / New Lows

  • Scans a user-defined lookback.
  • Marks RS new highs (blue) and new lows (red).
  • Modes for historical, last-bar-only, or “RS leads price.”


RS Rating (1–99)

  • Calculates a weighted performance score over 1–12 months.
  • Compares this score to market-wide thresholds pulled via request.seed().
  • Converts score into percentile bands (e.g., 70–89, 90–98).
  • Assigns 99 to top leaders and 1 to laggards.


Fallback Logic

  • Missing environment data = shows “RS” without a number.
  • Replay mode uses fixed thresholds to approximate ratings.


Output

  • Clean label showing RS Rating near the RS line.
  • Helps traders instantly judge whether a stock is a true leader.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.