Comparative Strength [FT]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © faliqzul

//@version=5
indicator(title="Comparative Strength [FT]", shorttitle="CS [FT]")
comparativeTickerId = input.symbol("AMEX:SPY", title="Comparative Symbol")

fastLen = input.int(5, title="Fast Length", tooltip="Calculates on X number of candles")
slowLen = input.int(13, title="Slow Length", tooltip="Calculates on X number of candles")
smoothing = input.int(3, title="Smoothing", tooltip="Smoothing by applying moving average")
comparativeSymbol = request.security(comparativeTickerId, "", hl2)

maDiff = math.log(ta.ema(hl2, fastLen)) - math.log(ta.ema(hl2, slowLen))
csDiff = math.log(ta.ema(comparativeSymbol, fastLen)) - math.log(ta.ema(comparativeSymbol, slowLen))

csDiv = ta.sma((maDiff - csDiff) * 100, smoothing)


plot(csDiv, title="C", color=color.orange)
h0 = hline(0, title="Zero Line", linestyle=hline.style_dashed, linewidth=1, color=#ababab)
