The following code is a TOS stock code for RSI. By default, an arrow is plotted when the rsi < over_bought and also when the rsi > over_sold. What I have been racking my brain to figure out how to plot an arrow, or point(doesnt matter) when rsi = rsi. In other word, when it is neither overbought nor oversold. In other words, the text that is bolded below. I've tried everything. Is there anyone that can help me with this?
programming is about using formulas to evaluate numbers.
if you want something different to happen, try to think of which variables and/or numbers to compare to to make it happen.
if you want to do something when rsi is neither overbought nor oversold, then rsi has a value between them.
for reference, the default values,
input over_Bought = 70;
input over_Sold = 30;
the easiest thing would be to set this built in setting to yes.
input showBreakoutSignals = no
then you will have an arrow on the first bar that rsi enters the 'normal' price range.
you could have created a formula to determine when rsi is in your desired range.
then use that variable to trigger something to happen on the chart.
def normal = if rsi < over_Bought and rsi > over_Sold then 1 else 0;
like moxiesmiley did, but use def instead of plot.
there is no reason to plot a boolean value on a chart with other values. the values, 0 or 1, are so small compared to the other values on the chart, that the changes can barely be seen. and it shifts the main plot, reducing its size.
instead of plotting the variable normal, use it to enable a row of points or some shading between 30 and 70, like in this version.
Ruby:
# rsi_normal_zone
# RSI
# TD Ameritrade IP Company, Inc. (c) 2007-2022
declare lower;
input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;
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;
plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN;
plot DownSignal = if RSI crosses below OverBought then OverBought else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
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"));
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
#-------------------------------------------
# copy original RSI and add this
def na = double.nan;
# add points at 50 , for normal zone
def normal = if rsi < over_Bought and rsi > over_Sold then 1 else 0;
input show_points_when_normal = yes;
plot p = if normal then 50 else na;
p.SetPaintingStrategy(PaintingStrategy.POINTS);
p.SetDefaultColor(Color.cyan);
p.setlineweight(2);
p.hidebubble();
# add shading when rsi is in normal zone
input show_shading_when_normal = yes;
def cloudtop = if normal then over_Bought else na;
def cloudbot = if normal then over_sold else na;
addcloud(cloudtop, cloudbot, color.gray, color.gray);
#
this shows both of these set to yes
input show_points_when_normal = yes;
input show_shading_when_normal = yes;
anyway to get a addlabel as a RSI,,sometime RSI indicator doesnt fit when i have a bunch of small charts on a flexible grid,,,, if possible to turn Red when below the 50 line and Green when it is above the 50 line,,,any assistance would be greatly appreciated
Exactly what i was looking for,, cant thank you enough,,,
while i have you attention.... is there anyway to add a specific aggregation period to this code? i like to use a 15 min RSI on 3minute chart when possible,,
also are you able to code something like this for A MACD LABEL,,, when histogram and lines are above Zero line, Label turns green, when both lines and histogram are below zero line label turns green, when histogram and lines are not both above or below zero line label turns yellow,,,
Exactly what i was looking for,, cant thank you enough,,,
while i have you attention.... is there anyway to add a specific aggregation period to this code? i like to use a 15 min RSI on 3minute chart when possible,,
also are you able to code something like this for A MACD LABEL,,, when histogram and lines are above Zero line, Label turns green, when both lines and histogram are below zero line label turns green, when histogram and lines are not both above or below zero line label turns yellow,,,
It works on whichever time frame you use it on. Now if you are wanting an mtf to show on multiple time frames on same chart, that take someone smarter than me. I do not code but just take parts of scripts and add them to make what I want. I do not use the macd but will look at it this weekend if you can post script of the one you use if it matters.
as it stands, on a daily chart, when rsi crosses below 30 at the close, the buy order hits the next day at the open. what i'd like to try is having the buy go off not on the open but at a price a certain percentage amount below the previous day's close. let's call it 4%. don't want to buy at the open. do want to buy at a price 4% below the previous day's close.
as it stands, on a daily chart, when rsi crosses below 30 at the close, the buy order hits the next day at the open. what i'd like to try is having the buy go off not on the open but at a price a certain percentage amount below the previous day's close. let's call it 4%. don't want to buy at the open. do want to buy at a price 4% below the previous day's close.
price
default, open[-1]
Defines price at which the order is added.
try defining a formula to be the buy level you want, then reference it in the addorder.
if the current candle range doesn't include your price, not sure if it will execute. and if it does, it would be unrealistic and useless.
Here is the image of the current RSI with Bubbles at the bottom chart. I just want the bubbles to be at the top chart at the price it crosses. https://tos.mx/svdImGN (still trying to figure out how to insert image - it only gives me a link option)
Two more questions:
1 - is there a way to make the bubble show on the left side of the price instead of the right side that overlaps the next bars?
2 - is there a way to make more distance between the bubble and the price location it points to?
Two more questions:
1 - is there a way to make the bubble show on the left side of the price instead of the right side that overlaps the next bars?
2 - is there a way to make more distance between the bubble and the price location it points to?
Hi everyone and happy Friday!! i was wondering if anyone knows the code to add horizontal levels in a lower indicator on TOS (Like RSI)? I am currently having to manually add them onto the indicator for every ticker I open up.
Hi everyone and happy Friday!! i was wondering if anyone knows the code to add horizontal levels in a lower indicator on TOS (Like RSI)? I am currently having to manually add them onto the indicator for every ticker I open up.
Ideally I want the tag to turn RED if the RSI is over 70 and turn Green if it's under 30, else it can be white or grey. Anyone know a script that does that?
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.
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.