//@version=6
// Use this indicator to compare how security is performing in compare with prefered index (SPX by default).
// > 0 outperforming
// < 0 underperforming
// Works best for weekly, but can be applied to monthly and daily charts. It will be rather useless to use it in smaller timeframes
// Apply it to SPX, industry index, sector index or other security in similar sector
// UPDATE 1: Added sector and industry as optional params. Leave them same as index if you don't want to use them
indicator("Mansfield Relative Strength indicator", overlay=false)
index = input.symbol(title="Index", defval="SP:SPX")
sector = input.symbol(title="Sector (optional)", defval="SP:SPX")
industry = input.symbol(title="Industry (optional)", defval="SP:SPX")
ma_type = input.string(title="Which moving average to use?", defval="WMA", options=["SMA", "WMA", "EMA"])
len_daily = input(title="MA length for Daily", defval=200)
len_weekly = input(title="MA length for Weekly", defval=52)
len_monthly = input(title="MA length for Monthly", defval=10)
len_other = input(title="MA length for all other periods", defval=52)
val = close
period = timeframe.period
len = period == "W" ? len_weekly : (period == "D" ? len_daily : (period == "M" ? len_monthly : len_other))
ma_func(x, length) =>
ma_type == "WMA" ? ta.wma(x, length) : (ma_type == "SMA" ? ta.sma(x, length) : ta.ema(x, length))
calc_mrs_func(x, ind, length) =>
security = request.security(ind, period, x)
((x / security) / ma_func((x / security), length) - 1) * 10
mrs_index = calc_mrs_func(val, index, len)
mrs_sector = calc_mrs_func(val, sector, len)
mrs_industry = calc_mrs_func(val, industry, len)
c = math.sign(mrs_index) + math.sign(mrs_sector) + math.sign(mrs_industry)
//bgcolor(c == 3 ? color.new(color.green, 80) : c == 2 ? color.new(color.green, 75) : c == 1 ? color.new(color.green, 70) : c == -1 ? color.new(color.red, 70) : c == -2 ? color.new(color.red, 75) : c == -3 ? color.new(color.red, 80) : color.gray)
p_mrs = plot(mrs_index, color=color.white, linewidth=1, title="MRS index")
p_ema = plot(ta.ema(mrs_index,len / 2), title="EMA of MRS index", linewidth=1, color=color.blue)
fill(p_mrs, p_ema, color=mrs_index > ta.ema(mrs_index,len / 2) ? color.new(color.yellow, 80) : na, title="Fill when MRS > EMA")
//plot(mrs_sector != mrs_index ? mrs_sector : na, linewidth=1, title="MRS sector")
//plot(mrs_industry != mrs_index ? mrs_industry : na, linewidth=1, title="MRS industry")
//hline(price=0, color=color.white, linestyle=hline.style_dashed, title="Zero baseline")
Overview
Mansfield Relative Strength indicator plots the resulting relative strength curve alongside an exponential moving average in a separate pane, highlighting when the indicator trades above its moving average. Positive values denote outperformance relative to the benchmark, whereas negative values reflect underperformance. Users can customize benchmark symbols, choose between SMA, WMA, or EMA smoothing, and set period lengths across daily, weekly, and monthly charts. It generates comparison data without execution rules.
Mansfield Relative Strength calculation
Benchmark comparison against index, sector, or industry
Selectable moving average types including WMA, SMA, and EMA
Timeframe-specific smoothing lengths for daily, weekly, and monthly charts
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Index
symbol
SP:SPX
index
Sector (optional)
symbol
SP:SPX
sector
Industry (optional)
symbol
SP:SPX
industry
Which moving average to use?
string
WMA
ma_type
MA length for Daily
int
200
len_daily
MA length for Weekly
int
52
len_weekly
MA length for Monthly
int
10
len_monthly
MA length for all other periods
int
52
len_other
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome
Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m
KamaFama is an indicator that translates a Freqtrade trading strategy into Pine Script for visualization. It combines Kaufman Adaptive Moving Average (KAMA), MAMA/FAMA calculations derived via Hilbert Transform, Williams %R, and correlation trend filters to ev
MultiIndicator combines multiple technical indicators into a single separate pane to save chart space. It calculates and displays market regime detection based on ordinary least squares regression, a Holt exponential smoothing crossover, normalized RSI, ADX, a
Calculates the Archer Moving Averages Trends (AMAT) indicator by comparing fast and slow Exponential Moving Averages (EMAs) alongside their slope directions. A bullish trend (+1) is identified when the fast EMA exceeds the slow EMA with both rising, while a be
This indicator plots two simple moving averages of close, one over five bars and one over twenty bars, in a separate pane. It shades the area between the two plots green when the shorter average is above the longer average and red when it is below. There are n