vitvlkv

Comparative Relative Strength

58 5 4
The Comparative Relative Strength indicator is calculated by dividing one security's price by a second security's price (the "base" security). The result of this division is the ratio, or relationship, between the two securities.
Remove from Favorite Scripts Add to Favorite Scripts
study("Comparative Relative Strength")
a = input("GOOG", type=symbol)
b = input("AAPL", type=symbol)
as = security(a, period, close)
bs = security(b, period, close)
plot(as/bs, title="CRS")
This script was updated: Comparative Relative Strength
mc16
2 years ago
Thanks for making this script, this indicator was heavily missing on TradingView.
The real problem with this code is that required to manually enter each ticker every time!
This is really time consuming and isn't efficient at all.
I don't have any clue how to code but parameter A (GOOG) should be automatically recognized and insert on the current chart we are looking at, while parameter B should be fixed (ex. SPY)
Will be great to have the possibility to add a moving average on it as well.
After using this script for the past few days I found out that results are slightly different from the price ratio of other charting software, how this could be?

Like I said, I can't code but I really need this indicator to work properly on TradingView and If there is something that I can do, well just contact me.

Thanks
mc16
Reply
vitvlkv MOD mc16
2 years ago
Hi! Thanks for feedback, here a modified version
Comparative Relative Strength (one arg version)
of CRS
Reply
vitvlkv MOD mc16
2 years ago
Here is a version with MA smoothing

study("Comparative Relative Strength", shorttitle="CRS")
a = tickerid
b = input("SPX500", type=symbol)
as = security(a, period, close)
bs = security(b, period, close)
plot(as/bs, title="CRS", color=gray)
len = input(10)
plot(sma(as/bs, len), color=navy)
Reply
mc16 vitvlkv
2 years ago
Absolutely perfect, thank you very much!
Really appreciated! good trading...
Reply
vitvlkv MOD vitvlkv
2 years ago
Republished this code
Comparative Relative Strength
here
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out