Short & Long Relative Strength
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RS-Magic

//@version=5
indicator('Short & Long Relative Strength', shorttitle='Short & Long RS')
source = input(title='Source', defval=close)
comparativeTickerId = input.symbol('NSE:NIFTY', title='Comparative Symbol')
showShortRS = input(defval=true, title='Show Short RS')
ShortLength = input.int(65, minval=1, title='Short RS Time Period')
showLongRS = input(defval=true, title='Show Long RS')
LongLength = input.int(123, minval=1, title='Long RS Time Period')
showZeroLine = input(defval=true, title='Show Zero Line')
baseSymbol = request.security(syminfo.tickerid, timeframe.period, source)
comparativeSymbol = request.security(comparativeTickerId, timeframe.period, source)
plot(showZeroLine ? 0 : na, title='Zero Line', linewidth=1, color=color.new(color.black, 0))
LongRS = baseSymbol / baseSymbol[LongLength] / (comparativeSymbol / comparativeSymbol[LongLength]) - 1
ShortRS = baseSymbol / baseSymbol[ShortLength] / (comparativeSymbol / comparativeSymbol[ShortLength]) - 1
plot(showShortRS ? ShortRS : na, title='Short RS', linewidth=2, color=color.new(color.black, 0))
plot(showLongRS ? LongRS : na, title='Long RS', linewidth=3)
