Help with adding chart bubbles

PT_Scalper

Member
VIP
Hi everyone,

Need a bit of assistance adding chart bubbles to the modified version of PersonsPivot below;

#MyPersonsPivotsDaily

input marketThreshold = 0.0025;
input timeFrame = {default DAY, "2 DAYS", "3 DAYS", "4 DAYS", WEEK, MONTH, "OPT EXP", QUARTER, YEAR};
input showOnlyToday = yes;
input applyPersonsLevelsFilter = yes;

assert(marketThreshold >= 0, "'market threshold' must not be negative: " + marketThreshold);

def marketType = {default DISABLED, NEUTRAL, BEARISH, BULLISH};

def PP2 = high(period = timeFrame)[2] + low(period = timeFrame)[2] + close(period = timeFrame)[2];

marketType = if !applyPersonsLevelsFilter then marketType.DISABLED else
if PP2[-1] > (PP2[-1] + PP2 + PP2[1]) / 3 + marketThreshold then marketType.BULLISH else
if PP2[-1] < (PP2[-1] + PP2 + PP2[1]) / 3 - marketThreshold then marketType.BEARISH else marketType.NEUTRAL;


plot R4;
plot R3;
plot R2;
plot R1;
#plot RR;
plot PP;
#plot SS;
plot S1;
plot S2;
plot S3;
plot S4;

if showOnlyToday and !IsNaN(close(period = timeFrame)[-1])
then {
R1 = Double.NaN;
R2 = Double.NaN;
R3 = Double.NaN;
R4 = Double.NaN;
PP = Double.NaN;
S1 = Double.NaN;
S2 = Double.NaN;
S3 = Double.NaN;
S4 = Double.NaN;
} else {
PP = (high(period = timeFrame)[1] + low(period = timeFrame)[1] + close(period = timeFrame)[1]) / 3;
R1 = 2 * PP - low(period = timeFrame)[1];
R2 = PP + high(period = timeFrame)[1] - low(period = timeFrame)[1];
R3 = R2 + high(period = timeFrame)[1] - low(period = timeFrame)[1];
R4 = R3 + high(period = timeFrame)[1] - low(period = timeFrame)[1];
S1 = 2 * PP - high(period = timeFrame)[1];
S2 = PP - high(period = timeFrame)[1] + low(period = timeFrame)[1];
S3 = S2 - high(period = timeFrame)[1] + low(period = timeFrame)[1];
S4 = S3 - high(period = timeFrame)[1] + low(period = timeFrame)[1];
}

#RR = if (marketType == marketType.BEARISH or marketType == marketType.NEUTRAL) then R1 else R2;
#SS = if (marketType == marketType.BULLISH or marketType == marketType.NEUTRAL) then S1 else S2;

#RR.setHiding(!applyPersonsLevelsFilter);
R1.setHiding(!applyPersonsLevelsFilter);
R2.setHiding(!applyPersonsLevelsFilter);
R3.setHiding(!applyPersonsLevelsFilter);
R4.setHiding(!applyPersonsLevelsFilter);
#SS.setHiding(!applyPersonsLevelsFilter);
S1.setHiding(!applyPersonsLevelsFilter);
S2.setHiding(!applyPersonsLevelsFilter);
S3.setHiding(!applyPersonsLevelsFilter);
S4.setHiding(!applyPersonsLevelsFilter);

PP.SetDefaultColor(color.magenta);
R1.SetDefaultColor(color.pink);
R2.SetDefaultColor(color.light_red);
R3.SetDefaultColor(color.red);
R4.SetDefaultColor(color.dark_red);
S1.SetDefaultColor(color.lime);
S2.SetDefaultColor(color.light_green);
S3.SetDefaultColor(color.green);
S4.SetDefaultColor(color.dark_green);

#SS.DefineColor("S1", GetColor(6));
#SS.DefineColor("S2", GetColor(6));
#SS.AssignValueColor(if SS == S1 then SS.color("S1") else SS.color("S2"));

#RR.DefineColor("R1", GetColor(5));
#RR.DefineColor("R2", GetColor(5));
#RR.AssignValueColor(if RR == R1 then RR.color("R1") else RR.color("R2"));

PP.SetStyle(Curve.SHORT_DASH);
#RR.SetStyle(Curve.SHORT_DASH);
R1.SetStyle(Curve.short_DASH);
R2.SetStyle(Curve.medium_DASH);
R3.SetStyle(Curve.long_dash);
R4.SetStyle(Curve.firm);
#SS.SetStyle(Curve.SHORT_DASH);
S1.SetStyle(Curve.short_DASH);
S2.SetStyle(Curve.medium_DASH);
S3.SetStyle(Curve.long_dash);
S4.SetStyle(Curve.firm);

def paintingStrategy = if timeframe == timeframe.WEEK then PaintingStrategy.line else if timeFrame == timeFrame.MONTH or timeFrame == timeFrame."OPT EXP" or timeFrame == timeFrame.QUARTER or timeFrame == timeFrame.YEAR then PaintingStrategy.LINE_VS_SQUARES else PaintingStrategy.LINE;

PP.SetPaintingStrategy(paintingStrategy);
#RR.SetPaintingStrategy(paintingStrategy);
R1.SetPaintingStrategy(paintingStrategy);
R2.SetPaintingStrategy(paintingStrategy);
R3.SetPaintingStrategy(paintingStrategy);
R4.SetPaintingStrategy(paintingStrategy);
#SS.SetPaintingStrategy(paintingStrategy);
S1.SetPaintingStrategy(paintingStrategy);
S2.SetPaintingStrategy(paintingStrategy);
S3.SetPaintingStrategy(paintingStrategy);
S4.SetPaintingStrategy(paintingStrategy);

AddChartBubble(IsNaN(pp) and !IsNaN(pp[1]), pp,“PP”, Color.magenta);

I've added chart bubbles before but not having success with this one.

Can someone add a bubble to the left side of the line (so it's not interfering with current chart price movement)?

Thanks in advance.
 
Hi everyone,

Need a bit of assistance adding chart bubbles to the modified version of PersonsPivot below;



I've added chart bubbles before but not having success with this one.

Can someone add a bubble to the left side of the line (so it's not interfering with current chart price movement)?

Thanks in advance.

The following code was added to replace your addchartbubble code. It allows you to move the optional left and/or right display of bubbles, which can be moved sideways at the bubblemover input.

Ruby:
#Bubbles Optional Left and/or Right Display - Movable Sideways------------------------
input bubblemover = 4;
def b = bubblemover;
def b1 = b + 1;

input showbubble_left = yes;
AddChartBubble(showbubble_left and IsNaN(PP[-b]) and !IsNaN(PP[-b1]), PP[-b1], “PP”, Color.MAGENTA);

input showbubble_right = yes;
AddChartBubble(showbubble_right and IsNaN(close[b]) and !IsNaN(close[b1]), PP[b1], “PP”, Color.MAGENTA);
#--------------------------------------------------------------------------------------

Capture.jpg
Ruby:
#MyPersonsPivotsDaily

input marketThreshold = 0.0025;
input timeFrame = {default DAY, "2 DAYS", "3 DAYS", "4 DAYS", WEEK, MONTH, "OPT EXP", QUARTER, YEAR};
input showOnlyToday = yes;
input applyPersonsLevelsFilter = yes;

Assert(marketThreshold >= 0, "'market threshold' must not be negative: " + marketThreshold);

def marketType = {default DISABLED, NEUTRAL, BEARISH, BULLISH};

def PP2 = high(period = timeFrame)[2] + low(period = timeFrame)[2] + close(period = timeFrame)[2];

marketType = if !applyPersonsLevelsFilter then marketType.DISABLED else
if PP2[-1] > (PP2[-1] + PP2 + PP2[1]) / 3 + marketThreshold then marketType.BULLISH else
if PP2[-1] < (PP2[-1] + PP2 + PP2[1]) / 3 - marketThreshold then marketType.BEARISH else marketType.NEUTRAL;


plot R4;
plot R3;
plot R2;
plot R1;
#plot RR;
plot PP;
#plot SS;
plot S1;
plot S2;
plot S3;
plot S4;

if showOnlyToday and !IsNaN(close(period = timeFrame)[-1])
then {
    R1 = Double.NaN;
    R2 = Double.NaN;
    R3 = Double.NaN;
    R4 = Double.NaN;
    PP = Double.NaN;
    S1 = Double.NaN;
    S2 = Double.NaN;
    S3 = Double.NaN;
    S4 = Double.NaN;
} else {
    PP = (high(period = timeFrame)[1] + low(period = timeFrame)[1] + close(period = timeFrame)[1]) / 3;
    R1 = 2 * PP - low(period = timeFrame)[1];
    R2 = PP + high(period = timeFrame)[1] - low(period = timeFrame)[1];
    R3 = R2 + high(period = timeFrame)[1] - low(period = timeFrame)[1];
    R4 = R3 + high(period = timeFrame)[1] - low(period = timeFrame)[1];
    S1 = 2 * PP - high(period = timeFrame)[1];
    S2 = PP - high(period = timeFrame)[1] + low(period = timeFrame)[1];
    S3 = S2 - high(period = timeFrame)[1] + low(period = timeFrame)[1];
    S4 = S3 - high(period = timeFrame)[1] + low(period = timeFrame)[1];
}

#RR = if (marketType == marketType.BEARISH or marketType == marketType.NEUTRAL) then R1 else R2;
#SS = if (marketType == marketType.BULLISH or marketType == marketType.NEUTRAL) then S1 else S2;

#RR.setHiding(!applyPersonsLevelsFilter);
R1.SetHiding(!applyPersonsLevelsFilter);
R2.SetHiding(!applyPersonsLevelsFilter);
R3.SetHiding(!applyPersonsLevelsFilter);
R4.SetHiding(!applyPersonsLevelsFilter);
#SS.setHiding(!applyPersonsLevelsFilter);
S1.SetHiding(!applyPersonsLevelsFilter);
S2.SetHiding(!applyPersonsLevelsFilter);
S3.SetHiding(!applyPersonsLevelsFilter);
S4.SetHiding(!applyPersonsLevelsFilter);

PP.SetDefaultColor(Color.MAGENTA);
R1.SetDefaultColor(Color.PINK);
R2.SetDefaultColor(Color.LIGHT_RED);
R3.SetDefaultColor(Color.RED);
R4.SetDefaultColor(Color.DARK_RED);
S1.SetDefaultColor(Color.LIME);
S2.SetDefaultColor(Color.LIGHT_GREEN);
S3.SetDefaultColor(Color.GREEN);
S4.SetDefaultColor(Color.DARK_GREEN);

#SS.DefineColor("S1", GetColor(6));
#SS.DefineColor("S2", GetColor(6));
#SS.AssignValueColor(if SS == S1 then SS.color("S1") else SS.color("S2"));

#RR.DefineColor("R1", GetColor(5));
#RR.DefineColor("R2", GetColor(5));
#RR.AssignValueColor(if RR == R1 then RR.color("R1") else RR.color("R2"));

PP.SetStyle(Curve.SHORT_DASH);
#RR.SetStyle(Curve.SHORT_DASH);
R1.SetStyle(Curve.SHORT_DASH);
R2.SetStyle(Curve.MEDIUM_DASH);
R3.SetStyle(Curve.LONG_DASH);
R4.SetStyle(Curve.FIRM);
#SS.SetStyle(Curve.SHORT_DASH);
S1.SetStyle(Curve.SHORT_DASH);
S2.SetStyle(Curve.MEDIUM_DASH);
S3.SetStyle(Curve.LONG_DASH);
S4.SetStyle(Curve.FIRM);

def paintingStrategy = if timeFrame == timeFrame.WEEK then PaintingStrategy.LINE else if timeFrame == timeFrame.MONTH or timeFrame == timeFrame."OPT EXP" or timeFrame == timeFrame.QUARTER or timeFrame == timeFrame.YEAR then PaintingStrategy.LINE_VS_SQUARES else PaintingStrategy.LINE;

PP.SetPaintingStrategy(paintingStrategy);
#RR.SetPaintingStrategy(paintingStrategy);
R1.SetPaintingStrategy(paintingStrategy);
R2.SetPaintingStrategy(paintingStrategy);
R3.SetPaintingStrategy(paintingStrategy);
R4.SetPaintingStrategy(paintingStrategy);
#SS.SetPaintingStrategy(paintingStrategy);
S1.SetPaintingStrategy(paintingStrategy);
S2.SetPaintingStrategy(paintingStrategy);
S3.SetPaintingStrategy(paintingStrategy);
S4.SetPaintingStrategy(paintingStrategy);

#Bubbles Optional Left and/or Right Display - Movable Sideways------------------------
input bubblemover = 4;
def b = bubblemover;
def b1 = b + 1;

input showbubble_left = yes;
AddChartBubble(showbubble_left and IsNaN(PP[-b]) and !IsNaN(PP[-b1]), PP[-b1], “PP”, Color.MAGENTA);

input showbubble_right = yes;
AddChartBubble(showbubble_right and IsNaN(close[b]) and !IsNaN(close[b1]), PP[b1], “PP”, Color.MAGENTA);
#--------------------------------------------------------------------------------------
 
The following code was added to replace your addchartbubble code. It allows you to move the optional left and/or right display of bubbles, which can be moved sideways at the bubblemover input.

Ruby:
#Bubbles Optional Left and/or Right Display - Movable Sideways------------------------
input bubblemover = 4;
def b = bubblemover;
def b1 = b + 1;

input showbubble_left = yes;
AddChartBubble(showbubble_left and IsNaN(PP[-b]) and !IsNaN(PP[-b1]), PP[-b1], “PP”, Color.MAGENTA);

input showbubble_right = yes;
AddChartBubble(showbubble_right and IsNaN(close[b]) and !IsNaN(close[b1]), PP[b1], “PP”, Color.MAGENTA);
#--------------------------------------------------------------------------------------
Can the showbubble_left / showbubble_right be put in the same line or do you have to have a line of code for each??
 
Can the showbubble_left / showbubble_right be put in the same line or do you have to have a line of code for each??

Here you go

Ruby:
input bubblemover = 4;
def b = bubblemover;
def b1 = b + 1;

input showbubble = {default right, left};
AddChartBubble(if showbubble == showbubble.left
                  then IsNaN(PP[-b]) and !IsNaN(PP[-b1])
               else if showbubble == showbubble.right
                  then IsNaN(close[b]) and !IsNaN(close[b1])
               else Double.NaN,
               if showbubble == showbubble.left
                  then PP[-b1]
               else if showbubble == showbubble.right
                  then PP[b1]
               else Double.NaN,
               “PP”, Color.MAGENTA);
 

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