ml_rs Relative Strength vs a benchmark

195
The leadership lens: how a name performs RELATIVE to a benchmark (NIFTY or any index you feed). Raw Dorsey RS, zero-centered Mansfield RS, a leadership state, a percentile rank for scanning a basket, and an RS slope — one shared definition so “outperforming”, “leading”, and “accelerating vs the index” mean the same thing across every scan.

Design (host-fed): you fetch the benchmark with request.security / input.source and pass its close in, so the library carries no hard-wired tickers and works on any instrument/benchmark. Every read is a pure function of the two series you pass; nothing repaints.

Concept credit: Relative Strength (Dorsey’s RS line) and Mansfield’s zero-centered RS (Stan Weinstein / Mansfield) are public technical-analysis techniques — this is an original, dependency-free Pine v6 packaging. Educational; not financial advice.

Library "ml_rs"

rs(price, indexPrice)
  Parameters:
    price (float)
    indexPrice (float)

mansfield(price, indexPrice, len)
  Parameters:
    price (float)
    indexPrice (float)
    len (simple int)

rsLeading(price, indexPrice, len)
  Parameters:
    price (float)
    indexPrice (float)
    len (simple int)

rsRank(price, indexPrice, len)
  Parameters:
    price (float)
    indexPrice (float)
    len (simple int)

rsSlope(price, indexPrice, slopeLen)
  Parameters:
    price (float)
    indexPrice (float)
    slopeLen (simple int)

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.