adding chartbubble on last bar of RSI

Kashkian

Member
I want to add chartbubble on last bar of RSI, I code as follow but it does not give value bubble on the last bar, can you please correct it?

addchartbubble(yes, rsi, rsi, if RSI<30 then color.cyan else if RSI>70 then color.magenta else color.yellow);
Thanks,
 
Solution
anyway to add bubble to the candle on the chart when its above the 50

Here is one way to add bubbles on the price chart at the crossing of the RSI 50. This is a mod to the standard TOS RSI used in my post above removing the declare lower, changing unnecessary plots to defs and adapting the up/dn breakout signals to the RSI 50 level.

Screenshot 2023-12-26 060720.png
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2023
#

#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...
I want to add chartbubble on last bar of RSI, I code as follow but it does not give value bubble on the last bar, can you please correct it?

addchartbubble(yes, rsi, rsi, if RSI<30 then color.cyan else if RSI>70 then color.magenta else color.yellow);
Thanks,

The following code includes 2 methods. You can choose which to add to the RSI code you are using.

Code:
#### Bubble at last bar using IsNaN(RSI[-1])
AddChartBubble(IsNaN(RSI[-1]), RSI, RSI, if RSI < 30 then Color.CYAN else if RSI > 70 then Color.MAGENTA else Color.YELLOW);

#### Bubble is movable
input bubble      = yes;
input bubblemover = 3;
def b  = bubblemover;
def b1 = b + 1;

AddChartBubble(bubble and !IsNaN(RSI[b1]) and IsNaN(RSI[b]), RSI[b1], RSI[b1], if RSI[b1] < 30 then Color.CYAN else if RSI[b1] > 70 then Color.MAGENTA else Color.YELLOW);

The first is a mod to just have the bubble at the last bar on the chart using isnan(rsi[-1]).

The second is a movable bubble using b and b1 to indentify the last bar's RSI when the bubble is moved by the number of bars input @ bubblemover.

You can see the difference in the image below.

Screenshot 2023-07-19 122525.png
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2023
#

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);

#### Bubble at last bar using IsNaN(RSI[-1])
AddChartBubble(IsNaN(RSI[-1]), RSI, RSI, if RSI < 30 then Color.CYAN else if RSI > 70 then Color.MAGENTA else Color.YELLOW);

#### Bubble is movable
input bubble      = yes;
input bubblemover = 3;
def b  = bubblemover;
def b1 = b + 1;

AddChartBubble(bubble and !IsNaN(RSI[b1]) and IsNaN(RSI[b]), RSI[b1], RSI[b1], if RSI[b1] < 30 then Color.CYAN else if RSI[b1] > 70 then Color.MAGENTA else Color.YELLOW);
 
Last edited:
anyway to add bubble to the candle on the chart when its above the 50

Here is one way to add bubbles on the price chart at the crossing of the RSI 50. This is a mod to the standard TOS RSI used in my post above removing the declare lower, changing unnecessary plots to defs and adapting the up/dn breakout signals to the RSI 50 level.

Screenshot 2023-12-26 060720.png
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2023
#

#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;

def RSI = 50 * (ChgRatio + 1);
def OverSold = over_Sold;
def OverBought = 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;

plot mid = 50;
plot midUpSignal = if RSI crosses above mid then mid else Double.NaN;
plot midDownSignal = if RSI crosses below mid then mid else Double.NaN;
midUpSignal.SetDefaultColor(Color.UPTICK);
midUpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
midDownSignal.SetDefaultColor(Color.DOWNTICK);
midDownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

#### Bubble at mid crossing
AddChartBubble(midUpSignal, low, "RSI\nUP", Color.GREEN, no);
AddChartBubble(midDownSignal, high, "RSI\nDN", Color.RED);

#
 
Solution

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
292 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