Relative Strength, COMPARITVE

Hello, i am new to community and afl programming, could you please help me for relative strength indicator like compare the current symbol with Index for any particular period like past 55 days, i have tradingview pine script for example and images

study("Relative Strength", shorttitle="RS", resolution="")
comparativeTickerId = input("SPX", type=input.symbol, title="Comparative Symbol")
lenght = input(50, type=input.integer, minval=1, title="Period")
showMA = input(defval=false, type=input.bool, title="Show Moving Average")
lenghtMA = input(10, type=input.integer, minval=1, title="Moving Average Period")
baseSymbol = security(syminfo.tickerid, timeframe.period, close)
comparativeSymbol = security(comparativeTickerId, timeframe.period, close)
hline(0, color=color.black, linestyle=hline.style_dotted)
res = baseSymbol / baseSymbol[lenght] / 
   (comparativeSymbol / comparativeSymbol[lenght]) - 1
plot(res, title="RS", color=#1155CC)
sma_1 = sma(res, lenghtMA)
plot(showMA ? sma_1 : na, color=color.gray)!

Capture

You need to show your OWN effort. The thing that you are asking for can be found using simple google search. Please follow this advice: How to ask a good question

Relative Strength is a BUILT-IN function. If you only searched the Google or manual (F1) you will find AFL Function Reference - RELSTRENGTH It is also available in "Charts" tab - just to be selected with one click.

You are expected to do basic search before posting.

5 Likes

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.