Help Making Bubbles for a custom Fibonacci Script!

Cooks Delta

New member
Hi traders Im new to the script game, I spent four hours just trying to get this script to plot yesterday's closing and opening candle, Just missing one last piece. It would make my day if anyone can help me just plot bubble labels for each fibonacci level I listed. Im really a noob so sorry in advance for my incompetence. Also the next thing I wanted to tackle was to make a similar script like this, except it plots out yesterday's close and the close of the first 30min bar as a fibonacci sequence. Would greatly appreciate the help and am eager to learn from explanations. Thank you!





plot Data = close;# Magic Fibonacci 1.272

# ...
declare upper;
declare hide_on_daily;
declare once_per_bar;

input showBubble = yes;
def vClose = close;
def nan = Double.NaN;

# debug and extra indicator flags
# could make input variables, but that makes
# the study name longer, and most people
# probably want these off by default
def showPrevClose = 0;
def showOpen = 0;

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

def dayOpen = if firstBarOfDay then open else dayOpen[1];
def prevDayClose = if lastBarOfDay then vClose else prevDayClose[1];

# fibs
def delta = if firstBarOfDay then dayOpen - prevDayClose else delta[1];


def fib4236 = if firstBarOfDay then prevDayClose + delta * 4.236 else fib4236[1];
def fib3618 = if firstBarOfDay then prevDayClose + delta * 3.618 else fib3618[1];
def fib1618 = if firstBarOfDay then prevDayClose + delta * 1.618 else fib1618[1];
def fib1272 = if firstBarOfDay then prevDayClose + delta * 1.272 else fib1272[1];
def fib100 = if firstBarOfDay then prevDayClose + delta * 1.00 else fib100[1];
def fib0618 = if firstBarOfDay then prevDayClose + delta * 0.618 else fib0618[1];
def fib0500 = if firstBarOfDay then prevDayClose + delta * 0.50 else fib0500[1];
def fib0382 = if firstBarOfDay then prevDayClose + delta * 0.382 else fib0382[1];
def fib0000 = if firstBarOfDay then prevDayClose + delta * 0.00 else fib0000[1];


#
plot fib = if firstBarOfDay[-1]then nan else fib4236;
addchartbubble (showbubble, fib[-1] == fib4236, "4.23%", color.orange, yes);
fib.SetDefaultColor(CreateColor(0,0,255));

plot fib1 = if firstBarOfDay[-1] then nan else fib3618;
fib1.SetDefaultColor(CreateColor(0,0,255));

plot fib2 = if firstBarOfDay[-1] then nan else fib1618;
fib2.SetDefaultColor(CreateColor(0,0,255));

plot fib3 = if firstBarOfDay[-1] then nan else fib1272;
fib3.SetDefaultColor(CreateColor(0,0,255));

plot fib4 = if firstBarOfDay[-1] then nan else fib100;
fib4.SetDefaultColor(CreateColor(0,0,255));

plot fib5 = if firstBarOfDay[-1] then nan else fib0618;
fib5.SetDefaultColor(CreateColor(0,0,255));

plot fib6 = if firstBarOfDay[-1] then nan else fib0500;
fib6.SetDefaultColor(CreateColor(0,0,255));

plot fib7 = if firstBarOfDay[-1] then nan else fib0382;
fib7.SetDefaultColor(CreateColor(0,0,255));

plot fib8 = if firstBarOfDay[-1] then nan else fib0000;
fib8.SetDefaultColor(CreateColor(0,0,255));




plot pOpen = if showOpen and !firstBarOfDay[-1] then dayOpen else nan;
plot pPrevClose = if showPrevClose and !lastBarOfDay[-1] then prevDayClose else nan;
pOpen.SetDefaultColor(CreateColor(0,255,0));
pPrevClose.SetDefaultColor(CreateColor(255,0,0));
 
Solution
Hi traders Im new to the script game, I spent four hours just trying to get this script to plot yesterday's closing and opening candle, Just missing one last piece. It would make my day if anyone can help me just plot bubble labels for each fibonacci level I listed. Im really a noob so sorry in advance for my incompetence. Also the next thing I wanted to tackle was to make a similar script like this, except it plots out yesterday's close and the close of the first 30min bar as a fibonacci sequence. Would greatly appreciate the help and am eager to learn from explanations. Thank you!





plot Data = close;# Magic Fibonacci 1.272

# ...
declare upper;
declare hide_on_daily;
declare once_per_bar;

input showBubble = yes;
def...
Hi traders Im new to the script game, I spent four hours just trying to get this script to plot yesterday's closing and opening candle, Just missing one last piece. It would make my day if anyone can help me just plot bubble labels for each fibonacci level I listed. Im really a noob so sorry in advance for my incompetence. Also the next thing I wanted to tackle was to make a similar script like this, except it plots out yesterday's close and the close of the first 30min bar as a fibonacci sequence. Would greatly appreciate the help and am eager to learn from explanations. Thank you!





plot Data = close;# Magic Fibonacci 1.272

# ...
declare upper;
declare hide_on_daily;
declare once_per_bar;

input showBubble = yes;
def vClose = close;
def nan = Double.NaN;

# debug and extra indicator flags
# could make input variables, but that makes
# the study name longer, and most people
# probably want these off by default
def showPrevClose = 0;
def showOpen = 0;

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

def dayOpen = if firstBarOfDay then open else dayOpen[1];
def prevDayClose = if lastBarOfDay then vClose else prevDayClose[1];

# fibs
def delta = if firstBarOfDay then dayOpen - prevDayClose else delta[1];


def fib4236 = if firstBarOfDay then prevDayClose + delta * 4.236 else fib4236[1];
def fib3618 = if firstBarOfDay then prevDayClose + delta * 3.618 else fib3618[1];
def fib1618 = if firstBarOfDay then prevDayClose + delta * 1.618 else fib1618[1];
def fib1272 = if firstBarOfDay then prevDayClose + delta * 1.272 else fib1272[1];
def fib100 = if firstBarOfDay then prevDayClose + delta * 1.00 else fib100[1];
def fib0618 = if firstBarOfDay then prevDayClose + delta * 0.618 else fib0618[1];
def fib0500 = if firstBarOfDay then prevDayClose + delta * 0.50 else fib0500[1];
def fib0382 = if firstBarOfDay then prevDayClose + delta * 0.382 else fib0382[1];
def fib0000 = if firstBarOfDay then prevDayClose + delta * 0.00 else fib0000[1];


#
plot fib = if firstBarOfDay[-1]then nan else fib4236;
addchartbubble (showbubble, fib[-1] == fib4236, "4.23%", color.orange, yes);
fib.SetDefaultColor(CreateColor(0,0,255));

plot fib1 = if firstBarOfDay[-1] then nan else fib3618;
fib1.SetDefaultColor(CreateColor(0,0,255));

plot fib2 = if firstBarOfDay[-1] then nan else fib1618;
fib2.SetDefaultColor(CreateColor(0,0,255));

plot fib3 = if firstBarOfDay[-1] then nan else fib1272;
fib3.SetDefaultColor(CreateColor(0,0,255));

plot fib4 = if firstBarOfDay[-1] then nan else fib100;
fib4.SetDefaultColor(CreateColor(0,0,255));

plot fib5 = if firstBarOfDay[-1] then nan else fib0618;
fib5.SetDefaultColor(CreateColor(0,0,255));

plot fib6 = if firstBarOfDay[-1] then nan else fib0500;
fib6.SetDefaultColor(CreateColor(0,0,255));

plot fib7 = if firstBarOfDay[-1] then nan else fib0382;
fib7.SetDefaultColor(CreateColor(0,0,255));

plot fib8 = if firstBarOfDay[-1] then nan else fib0000;
fib8.SetDefaultColor(CreateColor(0,0,255));




plot pOpen = if showOpen and !firstBarOfDay[-1] then dayOpen else nan;
plot pPrevClose = if showPrevClose and !lastBarOfDay[-1] then prevDayClose else nan;
pOpen.SetDefaultColor(CreateColor(0,255,0));
pPrevClose.SetDefaultColor(CreateColor(255,0,0));

Here are some chart bubbles that appear in the right expansion for the last fibs. You can move them sideways at the input bubblemover. There is a global color that you can change in the code or the input screen.

Screenshot-2022-11-02-051407.png
Ruby:
# Magic Fibonacci 1.272

# ...
declare upper;
declare hide_on_daily;
declare once_per_bar;

input showBubble = yes;
def vClose = close;
def nan = Double.NaN;

# debug and extra indicator flags
# could make input variables, but that makes
# the study name longer, and most people
# probably want these off by default
def showPrevClose = 0;
def showOpen = 0;

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

def dayOpen = if firstBarOfDay then open else dayOpen[1];
def prevDayClose = if lastBarOfDay then vClose else prevDayClose[1];

# fibs
def delta = if firstBarOfDay then dayOpen - prevDayClose else delta[1];


def fib4236 = if firstBarOfDay then prevDayClose + delta * 4.236 else fib4236[1];
def fib3618 = if firstBarOfDay then prevDayClose + delta * 3.618 else fib3618[1];
def fib1618 = if firstBarOfDay then prevDayClose + delta * 1.618 else fib1618[1];
def fib1272 = if firstBarOfDay then prevDayClose + delta * 1.272 else fib1272[1];
def fib100 = if firstBarOfDay then prevDayClose + delta * 1.00 else fib100[1];
def fib0618 = if firstBarOfDay then prevDayClose + delta * 0.618 else fib0618[1];
def fib0500 = if firstBarOfDay then prevDayClose + delta * 0.50 else fib0500[1];
def fib0382 = if firstBarOfDay then prevDayClose + delta * 0.382 else fib0382[1];
def fib0000 = if firstBarOfDay then prevDayClose + delta * 0.00 else fib0000[1];


#
plot fib = if firstBarOfDay[-1] then nan else fib4236;
AddChartBubble (showBubble, fib[-1] == fib4236, "4.23%", Color.ORANGE, yes);
fib.SetDefaultColor(CreateColor(0, 0, 255));

plot fib1 = if firstBarOfDay[-1] then nan else fib3618;
fib1.SetDefaultColor(CreateColor(0, 0, 255));

plot fib2 = if firstBarOfDay[-1] then nan else fib1618;
fib2.SetDefaultColor(CreateColor(0, 0, 255));

plot fib3 = if firstBarOfDay[-1] then nan else fib1272;
fib3.SetDefaultColor(CreateColor(0, 0, 255));

plot fib4 = if firstBarOfDay[-1] then nan else fib100;
fib4.SetDefaultColor(CreateColor(0, 0, 255));

plot fib5 = if firstBarOfDay[-1] then nan else fib0618;
fib5.SetDefaultColor(CreateColor(0, 0, 255));

plot fib6 = if firstBarOfDay[-1] then nan else fib0500;
fib6.SetDefaultColor(CreateColor(0, 0, 255));

plot fib7 = if firstBarOfDay[-1] then nan else fib0382;
fib7.SetDefaultColor(CreateColor(0, 0, 255));

plot fib8 = if firstBarOfDay[-1] then nan else fib0000;
fib8.SetDefaultColor(CreateColor(0, 0, 255));




plot pOpen = if showOpen and !firstBarOfDay[-1] then dayOpen else nan;
plot pPrevClose = if showPrevClose and !lastBarOfDay[-1] then prevDayClose else nan;
pOpen.SetDefaultColor(CreateColor(0, 255, 0));
pPrevClose.SetDefaultColor(CreateColor(255, 0, 0));


input bubblemover  = 3;
input showbubbles  = yes;
def bm             = bubblemover;
def bm1            = bm + 1;
def bubble         = showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]);
DefineGlobalColor("F", Color.CYAN);
AddChartBubble(bubble, fib[bm] , "4.236", GlobalColor("F"));
AddChartBubble(bubble, fib1[bm], "3.618", GlobalColor("F"));
AddChartBubble(bubble, fib2[bm], "1.618", GlobalColor("F"));
AddChartBubble(bubble, fib3[bm], "1.272", GlobalColor("F"));
AddChartBubble(bubble, fib4[bm], "1.000", GlobalColor("F"));
AddChartBubble(bubble, fib5[bm], "0.618", GlobalColor("F"));
AddChartBubble(bubble, fib6[bm], "0.500", GlobalColor("F"));
AddChartBubble(bubble, fib7[bm], "0.382", GlobalColor("F"));
AddChartBubble(bubble, fib8[bm], "0.000", GlobalColor("F"));





 
Solution
Here are some chart bubbles that appear in the right expansion for the last fibs. You can move them sideways at the input bubblemover. There is a global color that you can change in the code or the input screen.


Thanks a lot boss, I read the code to see how you put it together, genius. The language is starting to make a little sense, greatly appreciate the polish.
 
Here are some chart bubbles that appear in the right expansion for the last fibs. You can move them sideways at the input bubblemover. There is a global color that you can change in the code or the input screen.
Is it possible to base those same fibonacci plots off a different definition of the second plot? meaning instead of mapping it out from todays open to yesterdays close , to map it out from yesterdays close to todays 30min close of the first candle? im not sure how I would define that to make it work.
 

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