Can we plot RSI of one stock/indicator on a different stock?

Can we plot RSI of one stock/indicator on a different stock?

Friends,

checking if there is a possibility of plotting RSI of one stock on a different stocks chart in TOS?

Ex: I like to see ES RSI on TSLA or NVDA.

If yes, how can I do that
 
Close() has a parameter of 'symbol' and RSI() has a parameter of 'price' so you simply nest the reference.

Example:
Def googRSI = rsi(price = close(symbol = "goog"));
Thanks. Good to know.

But when I tried to plot I dont see the line the usual way we see for RSI.
I see the line is fragmented when I tired to plot the RSI of VIX in in the lower section on a TSLA 5 Min chart

am I doing it wrong?

INPUT LOOKUP_RSI = "VIX";
def LOOKUPRSI= rsi(price = close(symbol = LOOKUP_RSI), length = 5);
PLOT OBRSI = LOOKUPRSI;
 
To plot a study in the separate lower sections on ThinkorSwim you need to add

"Declare lower;"

Add that to the top of your code and I believe it'll solve the issue you're asking
 
To plot a study in the separate lower sections on ThinkorSwim you need to add

"Declare lower;"

Add that to the top of your code and I believe it'll solve the issue you're asking

Since VIX does not plot bars at the same times as TSLA, we need to provide values for missing bars. To do this, we need to use a 'recursive' to have the missing bars use the close price of the prior bar's close:
def c = if isnan( close(symbol = LOOKUP_RSI)) then ] else close(symbol = LOOKUP_RSI);
As the RSI uses an average, this change is also needed to provide the missing bars average values.

Here is the revised code with added overbought and oversold lines and RSI line coloring

The image shows the TSLA with the revised code and the VIX with the TOS native RSI indicator
Screenshot 2023-07-07 071927.png
Code:
declare lower;

input LOOKUP_RSI = "VIX";
def c = if IsNaN( close(symbol = LOOKUP_RSI)) then c[1] else  close(symbol = LOOKUP_RSI);
def LOOKUPRSI = RSI(price = c, length = 5);
plot OBRSI = LOOKUPRSI;

input over_Bought = 70;
input over_Sold   = 30;
plot OverSold   = over_Sold;
plot OverBought = over_Bought;

#
 
Since VIX does not plot bars at the same times as TSLA, we need to provide values for missing bars. To do this, we need to use a 'recursive' to have the missing bars use the close price of the prior bar's close:
def c = if isnan( close(symbol = LOOKUP_RSI)) then ] else close(symbol = LOOKUP_RSI);
As the RSI uses an average, this change is also needed to provide the missing bars average values.

Here is the revised code with added overbought and oversold lines and RSI line coloring

The image shows the TSLA with the revised code and the VIX with the TOS native RSI indicator
Thanks...makes sense.

Getting error while using your code. anything missing here?

INPUT LOOKUP_RSI = "VIX";
def LOOKUPRSI= rsi(price = close(symbol = LOOKUP_RSI), length = 5);
def c = if isnan(close(symbol = LOOKUP_RSI)) then ] else close(symbol = LOOKUP_RSI);
PLOT OBRSI = LOOKUPRSI;
 
Thanks...makes sense.

Getting error while using your code. anything missing here?

INPUT LOOKUP_RSI = "VIX";
def LOOKUPRSI= rsi(price = close(symbol = LOOKUP_RSI), length = 5);
def c = if isnan(close(symbol = LOOKUP_RSI)) then ] else close(symbol = LOOKUP_RSI);
PLOT OBRSI = LOOKUPRSI;
This is the code with line coloring
Code:
declare lower;

input LOOKUP_RSI = "VIX";
def c = if IsNaN( close(symbol = LOOKUP_RSI)) then c[1] else  close(symbol = LOOKUP_RSI);
def LOOKUPRSI = RSI(price = c, length = 5);
plot RSI = LOOKUPRSI;

input over_Bought = 70;
input over_Sold   = 30;
plot OverSold   = over_Sold;
plot OverBought = over_Bought;

RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > over_Bought then RSI.color("OverBought") else if RSI < over_Sold then RSI.color("OverSold") else RSI.color("Normal"));



#
 
@SleepyZ ~ This is great stuff. working as expected.

If I can ask can you add a code in the upper chart to draw a rectangle (previous 2 bars and current bar) if VIX RSI is overbought (say > 80) or VIX RSI is oversold (say < 20) and color the boxes differently (not to worry it is complicated)

This will plot dashed lines over the 3 bars you wanted at their highest(highs)/lowest(lows) with changeable colors (green for above overbought (UP) and red for below oversold (DN)) at the input screen. The extended portions of the dashed lines beyond three bars are colored black to match RTHours background and dark_gray to match the chart's ExtendHours to attempt to hide them.

Screenshot 2023-07-09 094728.png
Code:
input LOOKUP_RSI = "VIX";
def c = if IsNaN( close(symbol = LOOKUP_RSI)) then c[1] else  close(symbol = LOOKUP_RSI);
def LOOKUPRSI = RSI(price = c, length = 5);
def RSI = LOOKUPRSI;

input overBought = 80;
input overSold   = 20;
input lineweight = 2;
input arrows     = no;

def rth = SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) > 0;

plot up = RSI crosses above overBought;
up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
up.SetHiding(!arrows);

def uph = if up[-2] then Highest(high[-2], 3) else uph[1];
def upl = if up[-2] then Lowest(low[-2], 3) else upl[1];

plot xuph = uph;
xuph.SetPaintingStrategy(PaintingStrategy.DASHES);
xuph.AssignValueColor(if up or up[-1] or up[-2] then GlobalColor("UP") else if rth then GlobalColor("RTH") else GlobalColor("EXT"));
xuph.SetLineWeight(lineweight);

plot xupl = upl;
xupl.SetPaintingStrategy(PaintingStrategy.DASHES);
xupl.AssignValueColor(if up or up[-1] or up[-2] then GlobalColor("UP") else if rth then GlobalColor("RTH") else GlobalColor("EXT"));
xupl.SetLineWeight(lineweight);

plot dn = RSI crosses below overSold;
dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
dn.SetHiding(!arrows);

def dnh = if dn[-2] then Highest(high[-2], 3) else dnh[1];
def dnl = if dn[-2] then Lowest(low[-2], 3) else dnl[1];

plot xdnh = dnh;
xdnh.SetPaintingStrategy(PaintingStrategy.DASHES);
xdnh.AssignValueColor(if dn or dn[-1] or dn[-2] then GlobalColor("DN") else if rth then GlobalColor("RTH") else GlobalColor("EXT"));
xdnh.SetLineWeight(lineweight);

plot xdnl = dnl;
xdnl.SetPaintingStrategy(PaintingStrategy.DASHES);
xdnl.AssignValueColor(if dn or dn[-1] or dn[-2] then GlobalColor("DN") else if rth then GlobalColor("RTH") else GlobalColor("EXT"));
xdnl.SetLineWeight(lineweight);

DefineGlobalColor("UP", Color.GREEN);
DefineGlobalColor("DN", Color.RED);
DefineGlobalColor("RTH", Color.BLACK);
DefineGlobalColor("EXT", Color.DARK_GRAY);

#
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
332 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top