Relative Strength, not RSI
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jjustingreyy

//@version=5
indicator(title='Relative Strength, not RSI', shorttitle='not RSI')

// Input parameters
len = input(14, title='RSI Length')
src = input(close, title='Source')
HTF = input.timeframe('', 'TimeFrame')
lenMFI = input(14, title='Length MFI')
srcMFI = hlc3
smoothLen = input(5, title='Smooth Length')

// Calculate RSI
rsiSecurity(_symbol, _tf) =>
    _up = ta.rma(math.max(ta.change(src), 0), len)
    _down = ta.rma(-math.min(ta.change(src), 0), len)
    _down == 0 ? 100 : _up == 0 ? 0 : 100 - 100 / (1 + _up / _down)
rsi = request.security(syminfo.tickerid, HTF, rsiSecurity(syminfo.tickerid, HTF))

// Calculate MFI
mfiSecurity(_symbol, _tf) =>
    _upper = math.sum(volume * (ta.change(srcMFI) <= 0 ? 0 : srcMFI), lenMFI)
    _lower = math.sum(volume * (ta.change(srcMFI) >= 0 ? 0 : srcMFI), lenMFI)
    if _lower == 0
        100
    else if _upper == 0
        0
    else
        100.0 - 100.0 / (1.0 + _upper / _lower)
mfi = request.security(syminfo.tickerid, HTF, mfiSecurity(syminfo.tickerid, HTF))

// Calculate TRS using RSI and MFI
TRS = (rsi + mfi) / 2

// Smoothen the TRS line using SMA
smoothTRS = ta.sma(TRS, smoothLen)

// Determine trend color
trendColor = smoothTRS[1] < smoothTRS ? color.green : color.red

// Plot smoothed TRS with trend color, linewidth, and circles for color changes
TRS_plot = plot(smoothTRS, title='Smoothed TRS', color=trendColor, linewidth=2)

// Draw the Zero Line using line.new
line.new(x1=bar_index[1], y1=0, x2=bar_index, y2=0, width=1, color=color.gray, style=line.style_dotted)

// Plot circles when trend changes
trendSeries = smoothTRS[1] < smoothTRS ? 1 : 0
plotshape(ta.change(trendSeries) ? smoothTRS : na, title='Color Change Circle', location=location.absolute, style=shape.circle, size=size.tiny, color=trendColor, transp=0)