Help editing Chart Bubble

eulin87

Member
Hello! I'm no coder and giving it a try but I can't seem to get this right. I have been trading with the IB Pivot Point script. I am trying to add a bubble at the end of the fib level to label them. I have a bubble showing up already but the bubble is showing throughout the entire line. I just want it to show at the very end.

Screenshot-2022-07-06-200657.png


This is the current code

Shout out to @korygill by the way :)


Code:
# IB_Fib_Pivots
# Author: Kory Gill, @korygill
#
# VERSION HISTORY (sortable date and time (your local time is fine), and your initials
# 20190906-1900-KG    - Created.
# ...
# ...

declare hide_on_daily;
declare once_per_bar;

input AggregationPeriod = AggregationPeriod.DAY;

#
# logic
#
def nan = Double.NaN;
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def afterEnd = GetTime() > RegularTradingEnd(GetYYYYMMDD());
def firstBarOfDay = if (beforeStart[1] == 1 and beforeStart == 0) or (isRollover and beforeStart == 0) then 1 else 0;
def lastBarOfDay = if
    (afterEnd[-1] == 1 and afterEnd == 0) or
    (isRollover[-1] and firstBarOfDay[-1])
    then 1
    else 0;

#
# See this page for how to calculate the indicator
# https://www.interactivebrokers.com/en/software/tws/usersguidebook/technicalanalytics/fibonaccipivotpoints.htm
# Pivot Point (P) = (High + Low + Close)/3
# Support 1 (S1) = P - {.382 * (High - Low)}
# Support 2 (S2) = P - {.618 * (High - Low)}
# Support 3 (S3) = P - {1 * (High - Low)}
# Resistance 1 (R1) = P + {.382 * (High - Low)}
# Resistance 2 (R2) = P + {.618 * (High - Low)}
# Resistance 3 (R3) = P + {1 * (High - Low)}
#

def pc = close(period = AggregationPeriod)[1];
def ph = high(period = AggregationPeriod)[1];
def pl = low(period = AggregationPeriod)[1];

#Pivot Point (P) = (High + Low + Close)/3
#Support 1 (S1) = P - {.382 * (High - Low)}
#Support 2 (S2) = P - {.618 * (High - Low)}
#Support 3 (S3) = P - {1 * (High - Low)}
#Resistance 1 (R1) = P + {.382 * (High - Low)}
#Resistance 2 (R2) = P + {.618 * (High - Low)}
#Resistance 3 (R3) = P + {1 * (High - Low)}

def delta = ph - pl;
def pp = if firstBarOfDay then (pc + ph + pl) / 3 else if lastBarOfDay then nan else pp[1];
def s1 = if firstBarOfDay then pp - (.382 * delta) else if lastBarOfDay then nan else s1[1];
def s2 = if firstBarOfDay then pp - (.618 * delta) else if lastBarOfDay then nan else s2[1];
def s3 = if firstBarOfDay then pp - (1 * delta) else if lastBarOfDay then nan else s3[1];
def r1 = if firstBarOfDay then pp + (.382 * delta) else if lastBarOfDay then nan else r1[1];
def r2 = if firstBarOfDay then pp + (.618 * delta) else if lastBarOfDay then nan else r2[1];
def r3 = if firstBarOfDay then pp + (1 * delta) else if lastBarOfDay then nan else r3[1];

plot ppp = pp;
plot ps1 = s1;
plot ps2 = s2;
plot ps3 = s3;
plot pr1 = r1;
plot pr2 = r2;
plot pr3 = r3;

ppp.SetDefaultColor(Color.RED);
ps1.SetDefaultColor(Color.GREEN);
ps2.SetDefaultColor(Color.WHITE);
ps3.SetDefaultColor(Color.MAGENTA);
pr1.SetDefaultColor(Color.YELLOW);
pr2.SetDefaultColor(Color.VIOLET);
pr3.SetDefaultColor(Color.BLUE);

input showBubble =yes;
input showbubble_right = yes;
AddChartBubble(showbubble_right, PPP, “PP”, Color.white);
 
Last edited:
Solution
Hello! I'm no coder and giving it a try but I can't seem to get this right. I have been trading with the IB Pivot Point script. I am trying to add a bubble at the end of the fib level to label them. I have a bubble showing up already but the bubble is showing throughout the entire line. I just want it to show at the very end.

Screenshot-2022-07-06-200657.png


This is the current code

Shout out to @korygill by the way :)


Code:
# IB_Fib_Pivots
# Author: Kory Gill, @korygill
#
# VERSION HISTORY (sortable date and time (your local time is fine), and your initials
# 20190906-1900-KG    - Created.
# ...
# ...

declare hide_on_daily;
declare once_per_bar;

input AggregationPeriod = AggregationPeriod.DAY;

#
# logic
#
def nan = Double.NaN;
def isRollover...
Hello! I'm no coder and giving it a try but I can't seem to get this right. I have been trading with the IB Pivot Point script. I am trying to add a bubble at the end of the fib level to label them. I have a bubble showing up already but the bubble is showing throughout the entire line. I just want it to show at the very end.

Screenshot-2022-07-06-200657.png


This is the current code

Shout out to @korygill by the way :)


Code:
# IB_Fib_Pivots
# Author: Kory Gill, @korygill
#
# VERSION HISTORY (sortable date and time (your local time is fine), and your initials
# 20190906-1900-KG    - Created.
# ...
# ...

declare hide_on_daily;
declare once_per_bar;

input AggregationPeriod = AggregationPeriod.DAY;

#
# logic
#
def nan = Double.NaN;
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def afterEnd = GetTime() > RegularTradingEnd(GetYYYYMMDD());
def firstBarOfDay = if (beforeStart[1] == 1 and beforeStart == 0) or (isRollover and beforeStart == 0) then 1 else 0;
def lastBarOfDay = if
    (afterEnd[-1] == 1 and afterEnd == 0) or
    (isRollover[-1] and firstBarOfDay[-1])
    then 1
    else 0;

#
# See this page for how to calculate the indicator
# https://www.interactivebrokers.com/en/software/tws/usersguidebook/technicalanalytics/fibonaccipivotpoints.htm
# Pivot Point (P) = (High + Low + Close)/3
# Support 1 (S1) = P - {.382 * (High - Low)}
# Support 2 (S2) = P - {.618 * (High - Low)}
# Support 3 (S3) = P - {1 * (High - Low)}
# Resistance 1 (R1) = P + {.382 * (High - Low)}
# Resistance 2 (R2) = P + {.618 * (High - Low)}
# Resistance 3 (R3) = P + {1 * (High - Low)}
#

def pc = close(period = AggregationPeriod)[1];
def ph = high(period = AggregationPeriod)[1];
def pl = low(period = AggregationPeriod)[1];

#Pivot Point (P) = (High + Low + Close)/3
#Support 1 (S1) = P - {.382 * (High - Low)}
#Support 2 (S2) = P - {.618 * (High - Low)}
#Support 3 (S3) = P - {1 * (High - Low)}
#Resistance 1 (R1) = P + {.382 * (High - Low)}
#Resistance 2 (R2) = P + {.618 * (High - Low)}
#Resistance 3 (R3) = P + {1 * (High - Low)}

def delta = ph - pl;
def pp = if firstBarOfDay then (pc + ph + pl) / 3 else if lastBarOfDay then nan else pp[1];
def s1 = if firstBarOfDay then pp - (.382 * delta) else if lastBarOfDay then nan else s1[1];
def s2 = if firstBarOfDay then pp - (.618 * delta) else if lastBarOfDay then nan else s2[1];
def s3 = if firstBarOfDay then pp - (1 * delta) else if lastBarOfDay then nan else s3[1];
def r1 = if firstBarOfDay then pp + (.382 * delta) else if lastBarOfDay then nan else r1[1];
def r2 = if firstBarOfDay then pp + (.618 * delta) else if lastBarOfDay then nan else r2[1];
def r3 = if firstBarOfDay then pp + (1 * delta) else if lastBarOfDay then nan else r3[1];

plot ppp = pp;
plot ps1 = s1;
plot ps2 = s2;
plot ps3 = s3;
plot pr1 = r1;
plot pr2 = r2;
plot pr3 = r3;

ppp.SetDefaultColor(Color.RED);
ps1.SetDefaultColor(Color.GREEN);
ps2.SetDefaultColor(Color.WHITE);
ps3.SetDefaultColor(Color.MAGENTA);
pr1.SetDefaultColor(Color.YELLOW);
pr2.SetDefaultColor(Color.VIOLET);
pr3.SetDefaultColor(Color.BLUE);

input showBubble =yes;
input showbubble_right = yes;
AddChartBubble(showbubble_right, PPP, “PP”, Color.white);

you need to come up with a formula for the time parameter, the first, for the bubble, that will be true only once.
you can reference some bar, x bars away from the last bar, like this

https://usethinkscript.com/threads/bubble-placement-offset-in-thinkorswim.9392/#post-85145
 
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
464 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