RSI Highs Lows

shakib3585

Active member
VIP
Hello All,

I am looking for RSI script.
Using the ToS RSI calculation: RSI()
Adding a blue dot for new RSI highs and red dots for new RSI lows, within a given period.

For example,
if I choose my period to be 21,
  • each time the RSI makes a high considering the last 21 bars, it will show a blue dot on the RSI line.
  • The same is true for RSI making a new low considering the previous 21 bars; at that instant, a red dot would appear on the RSI line.

if I choose my period to be 52,
  • blue dot for new 52-bar RSI highs
  • red dots for new 52-bar RSI lows.
Also: the line should be green while increasing and red while decreasing
By increasing, I meant if the current RSI value is higher than the previous one and vice versa. Thank you so much!

Please help.

Thank you very much!
 
Last edited by a moderator:
Solution
Hello All,

I am looking for RSI script.
Using the ToS RSI calculation: RSI()
Adding a blue dot for new RSI highs and red dots for new RSI lows, within a given period.

For example,
if I choose my period to be 21,
  • each time the RSI makes a high considering the last 21 bars, it will show a blue dot on the RSI line.
  • The same is true for RSI making a new low considering the previous 21 bars; at that instant, a red dot would appear on the RSI line.

if I choose my period to be 52,
  • blue dot for new 52-bar RSI highs
  • red dots for new 52-bar RSI lows.
Also: the line should be green while increasing and red while decreasing
By increasing, I meant if the current RSI value is higher than the previous one and vice...
Hello All,

I am looking for RSI script.
Using the ToS RSI calculation: RSI()
Adding a blue dot for new RSI highs and red dots for new RSI lows, within a given period.

For example,
if I choose my period to be 21,
  • each time the RSI makes a high considering the last 21 bars, it will show a blue dot on the RSI line.
  • The same is true for RSI making a new low considering the previous 21 bars; at that instant, a red dot would appear on the RSI line.

if I choose my period to be 52,
  • blue dot for new 52-bar RSI highs
  • red dots for new 52-bar RSI lows.
Also: the line should be green while increasing and red while decreasing
By increasing, I meant if the current RSI value is higher than the previous one and vice versa. Thank you so much!

Please help.

Thank you very much!

i changed the bottom dot color to be magenta, so it would stand out more.

Code:
#rsi_dots_peaks

#https://usethinkscript.com/threads/rsi-highs-lows.19172/
#Using the ToS RSI calculation: RSI()
#Adding a blue dot for new RSI highs and red dots for new RSI lows, within a given period.

#  RSI
declare lower;

def na = double.nan;
def bn = barnumber();

input rsi_length = 14;
input rsi_over_Bought = 70;
input rsi_over_Sold = 30;
input rsi_price = close;
input rsi_averageType = AverageType.WILDERS;
#input showBreakoutSignals = no;

def NetChgAvg = MovingAverage(rsi_averageType, rsi_price - rsi_price[1], rsi_length);
def TotChgAvg = MovingAverage(rsi_averageType, AbsValue(rsi_price - rsi_price[1]), rsi_length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI = 50 * (ChgRatio + 1);
#def OverSold = rsi_over_Sold;
#def OverBought = rsi_over_Bought;
#def UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN;
#def 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);


def rsiup = rsi > rsi[1];
def rsidwn = rsi < rsi[1];
plot z = rsi;
z.AssignValueColor( if rsiup then color.green else if rsidwn then color.red else color.gray);

input past_bars = 21;
def newhi = (rsi > highest(rsi[1], past_bars));
def newlo = (rsi < lowest(rsi[1], past_bars));

plot pkdot = if newhi then rsi else na;
pkdot.SetPaintingStrategy(PaintingStrategy.POINTS);
pkdot.SetDefaultColor(Color.cyan);
pkdot.setlineweight(4);
pkdot.hidebubble();

plot valdot = if newlo then rsi else na;
valdot.SetPaintingStrategy(PaintingStrategy.POINTS);
valdot.SetDefaultColor(Color.magenta);
valdot.setlineweight(4);
valdot.hidebubble();
#
 

Attachments

  • img1.JPG
    img1.JPG
    32.6 KB · Views: 106
Solution
i changed the bottom dot color to be magenta, so it would stand out more.

Code:
#rsi_dots_peaks

#https://usethinkscript.com/threads/rsi-highs-lows.19172/
#Using the ToS RSI calculation: RSI()
#Adding a blue dot for new RSI highs and red dots for new RSI lows, within a given period.

#  RSI
declare lower;

def na = double.nan;
def bn = barnumber();

input rsi_length = 14;
input rsi_over_Bought = 70;
input rsi_over_Sold = 30;
input rsi_price = close;
input rsi_averageType = AverageType.WILDERS;
#input showBreakoutSignals = no;

def NetChgAvg = MovingAverage(rsi_averageType, rsi_price - rsi_price[1], rsi_length);
def TotChgAvg = MovingAverage(rsi_averageType, AbsValue(rsi_price - rsi_price[1]), rsi_length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI = 50 * (ChgRatio + 1);
#def OverSold = rsi_over_Sold;
#def OverBought = rsi_over_Bought;
#def UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN;
#def 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);


def rsiup = rsi > rsi[1];
def rsidwn = rsi < rsi[1];
plot z = rsi;
z.AssignValueColor( if rsiup then color.green else if rsidwn then color.red else color.gray);

input past_bars = 21;
def newhi = (rsi > highest(rsi[1], past_bars));
def newlo = (rsi < lowest(rsi[1], past_bars));

plot pkdot = if newhi then rsi else na;
pkdot.SetPaintingStrategy(PaintingStrategy.POINTS);
pkdot.SetDefaultColor(Color.cyan);
pkdot.setlineweight(4);
pkdot.hidebubble();

plot valdot = if newlo then rsi else na;
valdot.SetPaintingStrategy(PaintingStrategy.POINTS);
valdot.SetDefaultColor(Color.magenta);
valdot.setlineweight(4);
valdot.hidebubble();
#
Thank you so much @halcyonguy
 
Hey @halcyonguy, I was researching RDDT stock using the RSI developed by TOS and the one developed by you. The aggregation period is a Week. I noticed the beginning portion of the RSI is missing on your chart. I have attached the picture for reference. Can you please help me to resolve it?

pick almost any other stock and it works. RDDT only has data from 3/21, so not enough data.
when i change these, it draws a short line
input rsi_length = 8;
input past_bars = 6;
 

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

Thread starter Similar threads Forum Replies Date
C Simple MACD + RSI Indicator Questions 1
F RSI - doji signal Questions 0
S Multiple Time Frame RSI Questions 5
M EMAcross +RSI Watchlist Questions 1
R RSI-EMA-Bollinger Signal? Questions 1

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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