Untitled

 avatar
unknown
plain_text
2 months ago
1.6 kB
6
Indexable
//@version=5
indicator(title="KOMPOZIT RSN_RSI", shorttitle="KOM_RSN_RSI", precision=2, overlay=false)

src = close
rsiLength  = input.int(14, minval=1, title="RSI Length")

getHigherTimeframe() =>
    higherTimeFrame = timeframe.isweekly ? "M" : timeframe.isdaily ? "W" : timeframe.isintraday ? "D" : "D"
    higherTimeFrame

up = ta.rma(math.max(ta.change(src), 0), rsiLength)
down = ta.rma(-math.min(ta.change(src), 0), rsiLength)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))

// Comparative Relative Strength calculations
comparativeTickerId = input.symbol('BIST:XU100', title='Comparative Symbol')
baseSymbol = request.security(syminfo.tickerid, timeframe.period, src)
comparativeSymbol = request.security(comparativeTickerId, timeframe.period, src)
crs = baseSymbol / comparativeSymbol

higherRSI = ta.rsi(crs, rsiLength)

plot(rsi, title="RSI", linewidth=2, color=color.orange)
plot(higherRSI, title="RSN_RSI", linewidth=2, color=color.green)

hline(70, title="BullishLine", color=#ffffff, linestyle=hline.style_dashed)
hline(50, title="BearishLine", color=#e4aa0d, linestyle=hline.style_dashed)

rsiup  = ta.crossunder(higherRSI, 50)
rsidown  = ta.crossover(higherRSI, 50)

plotshape(rsiup ? 1 : na, force_overlay = true, location=location.belowbar, color=color.green, style=shape.labelup, title='AL', text='AL', size=size.normal, offset=-1)
plotshape(rsidown ? 1 : na, force_overlay = true, location=location.abovebar, color=color.red, style=shape.labeldown, title='SAT', text='SAT', size=size.normal, offset=-1)
Leave a Comment