RSI Watchlist Column for ThinkorSwim

Steve2286

New member
2019 Donor
Hi does anyone know how to add a watchlist column to ThinkorSwim that just show the current RSI value on a 5 min chart?

Code:
# RSI Watchlist Column
# Mobius

def c = if isNaN(close) then c[1] else close;
def NetChgAvg = Average(c - c[1], 14);
def TotChgAvg = Average(AbsValue(c - c[1]), 14);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
plot RSI = 50 * (ChgRatio + 1);
 

BenTen

Administrative
Staff
VIP
@Steve2286 That's already built into ToS. You just have to add it to your watchlist. By default it will show RSI on the daily chart. Be sure to change it if you can to use other timeframe.

v4SOYsi.png
 

otmane

New member
I wrote this code but i dont know if is correct or not sound like not give me good result

Code:
def ab =RSI()."RSI" is greater than RSI()."OverBought";
def bb = RSI()."RSI" is less than RSI()."OverSold";
plot value = if ab then 1 else if bb then -1 else 0;
AssignBackgroundColor(if value == 1 then color.YELLOW else if value == -1 then color.CYAN  else color.red);
value.AssignValueColor(if value == 1 then color.BLACK else if value == -1 then color.BLACK  else color.CURRENT);
 
Last edited by a moderator:

imrobert

New member
Hi, I have an RSI column on my watchlist and I would like to play a sound when it goes under 30.
I set up something in the thinkscript editor but it doesnt seem to work

def condition = if RSI < 30 then 1 else 0;
Alert(condition, ”oversold”, Alert.TICK, sound.ding);

Maybe I am doing something wrong?
Any help appreciated thank you!
 

TraderJ

New member
I feel your pain, I having been looking for help on this forum to no avail. I use a separate computer with 2 monitors to show 40 tickers in a flexible grid with the RSI loaded on each. That is the best way I have found to not miss any action. I have never had any luck with TOS alerts.
 
Yes you can, I have this alert set for RSI under 30 for symbols in my watch list. When you click the scan tab look two rows under it. You will see (Scan In) and next to it (Intersect With) Click those and find your watch list in the drop down menu. Set your scan and alert.
 

SugarTrader

Member
VIP
Hello,
I am adding the daily RSI value as a column in my watchlist.
If I pick price = close. Does it mean that the RSI value is updated only at the close of the day? If I want a more dynamic value. I have to choose (H+L)/2. Correct?
thanks

 

HighBredCloud

Well-known member
VIP
So I tried my best to do this on my own...but since I am not a coder I fell short once again. I am hoping that a competent coder can assist with my request.

I am looking for a RSI watchlist column that can be sortable and one that counts the amount of candles that are ABOVE or BELOW 50.

Here is what I came up with from the various lines of codes I put together. Would really appreciate the help. Thanks.

Code:
#RSI WatchList Column

input length = 14;
input over_Bought = 50;
input over_Sold = 50;
input price = close;
input averageType = AverageType.WILDERS;


def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
def BEAR = over_Sold;
def BULL = over_Bought;
def UpSignal = if RSI crosses above BEAR then BEAR else Double.NaN;
def DownSignal = if RSI crosses below BULL then BULL else Double.NaN;

#
def sState = if close < UpSignal then -100 else if close > DownSignal then 100 else 0;
def sCount = CompoundValue(1, If(sState == 0, 0, if sState != sState[1] then 1 else sCount[1] + 1), 0);
def sCounter = If(sState > 0, sCount, -sCount);

plot sData = sCounter;
sData.assignValueColor(if sState > 0 then color.green else if sState < 0 then color.red else color.current);

Here is a pic of what I am looking for...A RSI watch list column where it counts how many GREEN and RED candle there are above the 50.

GfCUb1k.png
 

benito_3

New member
VIP
To help with the BuyTheDip in my watchlist selection I wanted to add 5 levels of RSI coloring. I have this script:

Code:
input VLow =35;
input Low = 45;
input High = 55;
input VHigh = 65;

plot RSI = (if RSI()."RSI" is less than VLow then -2
else if RSI()."RSI" is greater than or equal to VLow and RSI()."RSI" is less than Low then -1
else if RSI()."RSI" is greater than or equal to Low and RSI()."RSI" is less than High then 0
else if RSI()."RSI" is greater than or equal to High and RSI()."RSI" is less than VHigh then 1
else RSI()."RSI" equals 2);

AssignBackgroundColor(if RSI equals -2 then Color.RED
else if RSI equals -1 then Color.LIGHT_RED
else if RSI equals 0 then Color.DARK_GRAY
else if RSI equals 1 then Color.GREEN
else if RSI equals 2 then Color.DARK_GREEN
else color.BLACK);      *** Added this final else to remove error, but don't think required, could have finished with ...2 then Color.DARK.GREEN; ?

RSI.assignValueColor (Color.BLACK);

***The issue am having is don’t ever get level “2” DARK_GREEN
***Also read about "def" but I removed them, seems to still work.  So when are "def" required?  Originally I added these but removed:

def RSIVLOw = RSI()."RSI" is less than VLow;
def RSILOw = RSI()."RSI" is greater than or equal to VLow and RSI()."RSI" is less than Low;
def RSIMid = RSI()."RSI" is greater than or equal to Low and RSI()."RSI" is less than High;
def RSIHigh = RSI()."RSI" is greater than or equal to High and RSI()."RSI" is less than VHigh;
def RSIVHigh = RSI()."RSI" is greater than or equal to VHigh;

Greatly appreciate your feedback.
 

benito_3

New member
VIP
Two questions/issues:

***I don’t ever get level “2” DARK_GREEN even when select stock charts with RSI pegged to well over 65
***Also trying to understand when are "def" statements required? Originally I added these but removed as it works without them.
 

BenTen

Administrative
Staff
VIP
@benito_3 This should work.

I modified the number sequence just so it's easier to understand.

Code:
input VLow =35;
input Low = 45;
input High = 55;
input VHigh = 65;

plot RSI = (if RSI()."RSI" is less than VLow then 1
else if RSI()."RSI" is greater than or equal to VLow and RSI()."RSI" is less than Low then 2
else if RSI()."RSI" is greater than or equal to Low and RSI()."RSI" is less than High then 3
else if RSI()."RSI" is greater than or equal to High and RSI()."RSI" is less than VHigh then 4
else 5);

AssignBackgroundColor(if RSI equals 1 then Color.RED
else if RSI equals 2 then Color.LIGHT_RED
else if RSI equals 3 then Color.DARK_GRAY
else if RSI equals 4 then Color.GREEN
else if RSI == 5 then Color.DARK_GREEN else color.gray);
 

benito_3

New member
VIP
I found the error. In the last "else" in the plot section, I was trying to make RSI()."RSI" equal to 2

Corrected line is:

Code:
else if RSI()."RSI" is greater than or equal to High and RSI()."RSI" is less than VHigh then 1 else 2);

Works great now and replaced the number color codes with just the RSI value itself:

Code:
input VLow =35;
input Low = 45;
input High = 55;
input VHigh = 65;

plot RSI = RSI()."RSI";

AssignBackgroundColor(if RSI is less than VLow then Color.RED
else if RSI is greater than or equal to VLow and RSI is less than Low then Color.LIGHT_RED
else if RSI is greater than or equal to Low and RSI is less than High then Color.DARK_GRAY
else if RSI is greater than or equal to High and RSI is less than VHigh then Color.LIGHT_GREEN
else Color.GREEN);

RSI.assignValueColor (Color.BLACK);
 

Similar threads

Top