RSI Format, Label, Watchlist, Scan For ThinkOrSwim

So say I want to scan for stocks with 2 conditions, and I want to add a third. Example being I want a stock where the RSI has not gone below 50 in the last 14 days(bars). Anyone know the proper way to say this without having to use condition wizard?
 

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

@mourningwood4521 If you can't figure it out just use the wizard and adapt that code to be a Study, Scanner, Watchlist, or whatever you want... Even those of us that code constantly use the wizard to speed coding because nobody can remember how to code using every Function and licensed Study... It's called prototyping... 💡
 
@mourningwood4521 Build your scanner through the conditional wizard first, then click on the "thinkscript Editor" tab to see the technical code.

ow04jZh.png


N56IvSb.png
 
Hello, I have been researching about this possibility for some time now but I haven't found anything. I want to add a label that displays the RSI value of the bar where the cursor is located, is this possible?
 
@Thinker20 That cannot be done in TOS... There no way to link on-hover to a chart label, or anything else for that matter, because the functionality doesn't exist...
 
The original script came with the 30 and the 70 line but I want to add the 50 line ( I draw the RED LINE on the attachment file)
 
Add this code to the bottom of your script...

Ruby:
plot midLine = 50;
midLine.SetDefaultColor(Color.RED);
midLine.SetLineWeight(2);
 
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.
 
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.
 
@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);
 
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);
 
Hey guys, I'm having trouble adding a label to a chart that looks at a study value from a 1 or 5 min chart and changes color based on whether or not that value is increasing. Let's say I want to reference the RSI of the 5 min and compare the value 1 bar ago to the current bar. I'm assuming you start with

Code:
def Period_Type = AggregationPeriod.FIVE_MIN;
def val_0 = reference RSI().close[0];
def val_1 = reference RSI().close[1];

AddLabel(yes, "RSI", if val_0>val_1 Color.Green else Color.Red);

It's erroring out with the add label as I'm assuming it doesn't like the reference RSI().close. Secondly I'm not 100% positive that the reference RSI is even referencing the right aggregation period either. Anyone have an idea how to do this?
 
@itsthefriz I think you were on the right track, but over-complicating things... You don't need to use aggregation because RSI will be based on whatever the timeframe of your chart is using... Try the following... Compare it to your code and you'll see just how close you were...

Ruby:
def rsi = RSI();
AddLabel(yes, "RSI", if rsi > rsi[1] then Color.Green else if rsi < rsi[1] then Color.Red else Color.Gray);

@BenTen I already had the reply typed up before you moved the original topic...
 
@BenTen thanks for the help, however the study I was planning on using is a custom study based off of DemandIndex, but used RSI because everyone here's pretty familiar with it. In the code the hope was to use 'reference' as it seemed like that would be easier to reference the study rather than duplicate it. Do you know if it's possible to use reference (study) with a different aggregation period or will it always reference that study based on the time period of the chart? Secondly I can duplicate the DemandIndex and remove the plot but can't get it to appear on a 15m chart when the study's aggregation period is 1m. If the aggregation period is set to 15m then the chart I use is 5m then the 15m time frame label displays fine.

@rad14733 I'm more of a swing trader so I don't spend much time on low time frame charts...it makes me too myopic haha, was just curious to see how a study interacts on low TF's near S/R levels without having to go there and watch it, ya know? The rsi<rsi[1] helped a lot though!

Code:
declare lower;
def TimeFrame = AggregationPeriod.FIFTEEN_MIN;

input length = 5;

def wClose =(high(period = TimeFrame) + low(period = TimeFrame) + 2 * close(period=TimeFrame)) * 0.25;
def wCRatio = (wClose - wClose[1]) / Min(wClose, wClose[1]);
def closeRatio = 3 * wClose / Average(Highest(High(period = TimeFrame), 2) - Lowest(Low(period = TimeFrame), 2), length) * AbsValue(wCRatio);
def volumeRatio = Volume(period = TimeFrame) / Average(Volume(period = TimeFrame), length);
def volumePerClose = volumeRatio / exp(Min(88, closeRatio));
def buyP;
def sellP;
if (wCRatio > 0) {
    buyP = volumeRatio;
    sellP = volumePerClose;
} else {
    buyP = volumePerClose;
    sellP = volumeRatio;
}
def buyPres = if IsNaN(buyPres[1]) then 0 else ((buyPres[1] * (length - 1)) + buyP) / length;
def sellPres = if IsNaN(sellPres[1]) then 0 else ((sellPres[1] * (length - 1)) + sellP) / length;
def tempDI;
if ((((sellPres[1] * (length - 1)) + sellP) / length - ((buyPres[1] * (length - 1)) + buyP) / length) > 0) {
    tempDI = - if (sellPres != 0) then buyPres / sellPres else 1;
} else {
    tempDI = if (buyPres != 0) then sellPres / buyPres else 1;
}
def DMIndx = if IsNaN(close(period = TimeFrame)) then Double.NaN else if tempDI < 0 then -1 - tempDI else 1 - tempDI;
def ZeroLine = 0;

AddLabel(yes, "DemandIndex: " + DMIndx, if DMIndx>DMIndx[1] then Color.Green else Color.Red);

#DMIndx.setDefaultColor(GetColor(1));
#ZeroLine.SetDefaultColor(GetColor(5));
 
@Mascapitalllctrader The open of a new 5 min candle is the same as the close of the previous 5 min candle so if 5 min RSI closes below 30 then it should satisfy your condition. Should be pretty easy to set an alert.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
414 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