OPEN-SOURCE SCRIPT

Relative Strength (RS) - Mansfield Style

230
Relative Strength (RS) measures how a symbol performs against a chosen
benchmark. Instead of plotting the raw price ratio — whose scale differs
from one symbol to another and makes comparison difficult — this script
normalizes the ratio (symbol close / benchmark close) against its own
simple moving average over a configurable lookback "Period". The result
is a zero-centered line that reads the same way on any symbol:

- RS above 0 and rising → the asset is outperforming the benchmark
- RS below 0 and falling → the asset is underperforming
- Zero-line crossings → shifts in relative leadership

Only the direction and the position relative to zero matter, not the
absolute value.

█ HOW IT WORKS

1. The script requests the benchmark's close on the selected timeframe.
2. It computes the raw ratio: symbol close / benchmark close.
3. The ratio is divided by its SMA over the "Period" lookback, minus 1 —
expressing how far the current relative strength stands above or
below its recent average.
4. An optional moving average of RS can be displayed as a signal line.

█ INPUTS

- Comparative Symbol: the benchmark (an index such as SPX, a sector
index, or any peer symbol — e.g. compare gold against silver).
- Period (default 50): normalization lookback. Shorter = more reactive,
longer = smoother and slower.
- Show Moving Average / Moving Average Period: optional smoothing line.
- Timeframe: leave empty to use the chart's timeframe, or select a
higher timeframe for multi-timeframe analysis.

█ HOW TO USE

Apply the indicator to any symbol. When RS holds above zero, the asset
is leading its benchmark — favor it for relative-strength strategies
(buy strength). When RS holds below zero, the asset is lagging — avoid
it or rotate out. Zero-line crossovers flag early changes in relative
leadership, and two built-in alerts fire on these crossings.

RS is a relative tool, not a timing tool: an asset can outperform a
falling benchmark while still declining in absolute terms. Combine it
with your own trend or entry criteria.

█ CREDITS

The normalization method follows the Mansfield Relative Strength
concept popularized by Stan Weinstein in "Secrets for Profiting in
Bull and Bear Markets".

█ NOTE ON HIGHER TIMEFRAMES

When a higher timeframe is selected in the Timeframe input, the value
of the current forming bar updates until that bar closes. Historical
values do not repaint.

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.