# Fibonacci Pivot Points for ThinkOrSwim

#### ArrOne

##### New member
2019 Donor
Is there any indicator out there that plots pivots using fibs?

Fibonacci Pivot Point = (High + Low + Close) / 3
S1 = Fibonacci Pivot – 0.382 * (High – Low)
S2 = Fibonacci Pivot – 0.618 * (High – Low)
S3 = Fibonacci Pivot – 1.000 * (High – Low)
R1 = Fibonacci Pivot + 0.382 * (High – Low)
R2 = Fibonacci Pivot + 0.618 * (High – Low)
R3 = Fibonacci Pivot + 1.000 * (High – Low)

Have you tried searching for it on here? I think we posted a few Fibs and Pivots related indicators.

This study is the thinkorswim version of the same study for Interactive Brokers.

The description of the study is found here:
https://www.interactivebrokers.com/...k/technicalanalytics/fibonaccipivotpoints.htm

This is what it looks like on the IB chart This is what it looks like on the thinkorswim chart The code is the fibs based on prev day close (could change to weekly, monthly if desired with some modification).

Pivot point studies highlight prices considered to be a likely turning point when looking at values from a previous period, whether it be daily, weekly, quarterly or annual. Each pivot point study has its own characteristics on how these points are calculated. The formula applied for the Fibonacci Pivot Points is:

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

### thinkScript code

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();
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def afterEnd = GetTime() > RegularTradingEnd(GetYYYYMMDD());
def firstBarOfDay = if (beforeStart == 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;

#
# 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);
def ph = high(period = AggregationPeriod);
def pl = low(period = AggregationPeriod);

#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;
def s1 = if firstBarOfDay then pp - (.382 * delta) else if lastBarOfDay then nan else s1;
def s2 = if firstBarOfDay then pp - (.618 * delta) else if lastBarOfDay then nan else s2;
def s3 = if firstBarOfDay then pp - (1 * delta) else if lastBarOfDay then nan else s3;
def r1 = if firstBarOfDay then pp + (.382 * delta) else if lastBarOfDay then nan else r1;
def r2 = if firstBarOfDay then pp + (.618 * delta) else if lastBarOfDay then nan else r2;
def r3 = if firstBarOfDay then pp + (1 * delta) else if lastBarOfDay then nan else r3;

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

https://tos.mx/xPiy57

#### Attachments

• • BillW, quijanoj44, SJP07 and 5 others
This code does not seem to plot correctly?

• json12
@RDMercer are you saying the two screenshots I included in the original post do not work for you, or you found some condition where the study does not work? Your post gives no insight into what does not work for you.

• BenTen
@RDMercer are you saying the two screenshots I included in the original post do not work for you, or you found some condition where the study does not work? Your post gives no insight into what does not work for you.
The study seems not to function over all time frames other than intra day or short time frame integration. (1min, 5min, etc) It doesn't work for a 1 y 1d or Wk or larger time frame. Granted, this mat be as designed / intended, might not have every setting 100% correct, or perhaps I misunderstood the study functionality to start with.

Ahh...I put this in the original post

The code is the fibs based on prev day close (could change to weekly, monthly if desired with some modification).

It would take more work to have this work on all charts/time frames.

• RDMercer
I can get this script to work in the post and pre market?

Does anyone know how to run a scan using a program available here that would allow me to find stocks that crossed above the Fibonacci Pivot Point on the Daily Chart? I don't want Support lines 123 or Resistance lines 123 just the Fibonacci Pivot point.
Thanks

Hello, does anyone know where i can find the fibonacci pivot point indicator?
I found it for tradingview. The indicator shows on the chart the monthly fibonacci level and
three support and resistance levels as a line. I find the indicator very useful.
Thanks

It doesn´t calculate the pivot levels for the month correctly, instead it´s calculating only for the last day.
I would like to get the monthly pivot levels and plotted them on the daily.

Hello, does anyone know where i can find the fibonacci pivot point indicator?
I found it for tradingview. The indicator shows on the chart the monthly fibonacci level and
three support and resistance levels as a line. I find the indicator very useful.
Thanks Ruby:
``````#Fibonacci Pivot Points

input timeFrame     = AggregationPeriod.DAY;
input displace      = 0;#hint displace: 0=Today; 1=Yesterday; .... etc;
input lines         = {default dashes, points, triangles, horizontal, squares};
input showOnlyToday = no;

input showBubble    = yes;
input ShiftBubble   = 5;
def   n1            = ShiftBubble + 1;

def range           = (high(period = timeFrame)[displace] - low(period = timeFrame)[displace]) ;

plot R4;
plot R3;
plot R2;
plot R1;
plot PP;
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)[displace] + low(period = timeFrame)[displace] + close(period = timeFrame)[displace]) / 3;
R1 = PP + (range * .382);
R2 = PP + (range * .618);
R3 = PP + (range * 1.0);
R4 = PP + (range * 1.618);
S1 = PP - (range * .382);
S2 = PP - (range * .618);
S3 = PP - (range * 1.0);
S4 = PP - (range * 1.618);

}

PP.SetDefaultColor(Color.WHITE);
R1.SetDefaultColor(Color.RED);
R2.SetDefaultColor(Color.RED);
R3.SetDefaultColor(Color.RED);
R4.SetDefaultColor(Color.RED);
S1.SetDefaultColor(Color.GREEN);
S2.SetDefaultColor(Color.GREEN);
S3.SetDefaultColor(Color.GREEN);
S4.SetDefaultColor(Color.GREEN);

def paintingStrategy = if lines == lines.points then PaintingStrategy.POINTS
else if lines == lines.triangles then PaintingStrategy.TRIANGLES
else if lines == lines.dashes then PaintingStrategy.DASHES
else if lines == lines.horizontal then PaintingStrategy.HORIZONTAL
else PaintingStrategy.SQUARES;

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

def cond = showBubble and IsNaN(close[ShiftBubble]) and !IsNaN(close[n1]) ;
input show_bubble_price = yes;
AddChartBubble(cond, R1, "R1\n" + (if !show_bubble_price then Double.NaN else Round(R1)), Color.MAGENTA);
AddChartBubble(cond, R2, "R2\n" + (if !show_bubble_price then Double.NaN else Round(R2)), Color.MAGENTA);
AddChartBubble(cond, R3, "R3\n" + (if !show_bubble_price then Double.NaN else Round(R3)), Color.MAGENTA);
AddChartBubble(cond, R4, "R4\n" + (if !show_bubble_price then Double.NaN else Round(R4)), Color.MAGENTA);
AddChartBubble(cond, PP, "PP\n" + (if !show_bubble_price then Double.NaN else Round(PP)), Color.MAGENTA);
AddChartBubble(cond, S1, "S1\n" + (if !show_bubble_price then Double.NaN else Round(S1)), Color.MAGENTA);
AddChartBubble(cond, S2, "S2\n" + (if !show_bubble_price then Double.NaN else Round(S2)), Color.MAGENTA);
AddChartBubble(cond, S3, "S3\n" + (if !show_bubble_price then Double.NaN else Round(S3)), Color.MAGENTA);
AddChartBubble(cond, S4, "S4\n" + (if !show_bubble_price then Double.NaN else Round(S4)), Color.MAGENTA);

PP.HideBubble();
R1.HideBubble();
R2.HideBubble();
R3.HideBubble();
R4.HideBubble();
S1.HideBubble();
S2.HideBubble();
S3.HideBubble();
S4.HideBubble();
#####``````

• mberb, SJP07 and s1111
The Displace on this code should actually be 1.

i am trying to add chart bubbles to the lines. trying to mess with the code but im not so good at it. Any help please? Anyway to convert this to only show during regular trading hours?

And also possible to plot the Mid Points as well? Thank you!

Last edited by a moderator:
Hi, I found this indicator in the forum, I would like to add color painted area between 0,5-0.618 fib and 1.00-1.38 fib (the same with -0,5- to 0,618 and -1.00 to -1.382).
Code:
``````#Fibonacci Pivot Points

input timeFrame     = AggregationPeriod.DAY;
input displace      = 0;#hint displace: 0=Today; 1=Yesterday; .... etc;
input lines         = {default dashes, points, triangles, horizontal, squares};
input showOnlyToday = no;

input showBubble    = yes;
input ShiftBubble   = 5;
def   n1            = ShiftBubble + 1;

def range           = (high(period = timeFrame)[displace] - low(period = timeFrame)[displace]) ;

plot R4;
plot R3;
plot R2;
plot R1;
plot PP;
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)[displace] + low(period = timeFrame)[displace] + close(period = timeFrame)[displace]) / 3;
R1 = PP + (range * .5);
R2 = PP + (range * .618);
R3 = PP + (range * 1.0);
R4 = PP + (range * 1.382);
S1 = PP - (range * .5);
S2 = PP - (range * .618);
S3 = PP - (range * 1.0);
S4 = PP - (range * 1.382);

}

PP.SetDefaultColor(Color.WHITE);
R1.SetDefaultColor(Color.RED);
R2.SetDefaultColor(Color.RED);
R3.SetDefaultColor(Color.RED);
R4.SetDefaultColor(Color.RED);
S1.SetDefaultColor(Color.GREEN);
S2.SetDefaultColor(Color.GREEN);
S3.SetDefaultColor(Color.GREEN);
S4.SetDefaultColor(Color.GREEN);

def paintingStrategy = if lines == lines.points then PaintingStrategy.POINTS
else if lines == lines.triangles then PaintingStrategy.TRIANGLES
else if lines == lines.dashes then PaintingStrategy.DASHES
else if lines == lines.horizontal then PaintingStrategy.HORIZONTAL
else PaintingStrategy.SQUARES;

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

def cond = showBubble and IsNaN(close[ShiftBubble]) and !IsNaN(close[n1]) ;
input show_bubble_price = yes;
AddChartBubble(cond, R1, "R1\n" + (if !show_bubble_price then Double.NaN else Round(R1)), Color.MAGENTA);
AddChartBubble(cond, R2, "R2\n" + (if !show_bubble_price then Double.NaN else Round(R2)), Color.MAGENTA);
AddChartBubble(cond, R3, "R3\n" + (if !show_bubble_price then Double.NaN else Round(R3)), Color.MAGENTA);
AddChartBubble(cond, R4, "R4\n" + (if !show_bubble_price then Double.NaN else Round(R4)), Color.MAGENTA);
AddChartBubble(cond, PP, "PP\n" + (if !show_bubble_price then Double.NaN else Round(PP)), Color.MAGENTA);
AddChartBubble(cond, S1, "S1\n" + (if !show_bubble_price then Double.NaN else Round(S1)), Color.MAGENTA);
AddChartBubble(cond, S2, "S2\n" + (if !show_bubble_price then Double.NaN else Round(S2)), Color.MAGENTA);
AddChartBubble(cond, S3, "S3\n" + (if !show_bubble_price then Double.NaN else Round(S3)), Color.MAGENTA);
AddChartBubble(cond, S4, "S4\n" + (if !show_bubble_price then Double.NaN else Round(S4)), Color.MAGENTA);

PP.HideBubble();
R1.HideBubble();
R2.HideBubble();
R3.HideBubble();
R4.HideBubble();
S1.HideBubble();
S2.HideBubble();
S3.HideBubble();
S4.HideBubble();
#####``````

This will do one of them, the rest can be copied and pasted, and easily edited.

Code:
``````#this can be used for everything, don't repeat it.
Def Toggle =
if !Toggle and R1 != R1 then Yes
else if Toggle and R1 != R1 then No
else Toggle
;

#This will create one of the levels, repeat this for other levels.
#Change top1a to top2a, etc. Change R1 and R2 to what ever you want.

Def Top1a; Def Bot1a;
Def Top1b; Def Bot1b;

if Toggle {
Top1a = R1;
Top1b = Double.NaN;
Bot1a = R2;
Bot1b = Double.NaN;
} else {
Top1a = Double.NaN;
Top1b = R1;
Bot1a = Double.NaN;
Bot1b = R2;

}

This study is the thinkorswim version of the same study for Interactive Brokers.

The description of the study is found here:
https://www.interactivebrokers.com/...k/technicalanalytics/fibonaccipivotpoints.htm

This is what it looks like on the IB chart

View attachment 5342

This is what it looks like on the thinkorswim chart

View attachment 5344

The code is the fibs based on prev day close (could change to weekly, monthly if desired with some modification).

Pivot point studies highlight prices considered to be a likely turning point when looking at values from a previous period, whether it be daily, weekly, quarterly or annual. Each pivot point study has its own characteristics on how these points are calculated. The formula applied for the Fibonacci Pivot Points is:

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

### thinkScript code

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();
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def afterEnd = GetTime() > RegularTradingEnd(GetYYYYMMDD());
def firstBarOfDay = if (beforeStart == 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;

#
# 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);
def ph = high(period = AggregationPeriod);
def pl = low(period = AggregationPeriod);

#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;
def s1 = if firstBarOfDay then pp - (.382 * delta) else if lastBarOfDay then nan else s1;
def s2 = if firstBarOfDay then pp - (.618 * delta) else if lastBarOfDay then nan else s2;
def s3 = if firstBarOfDay then pp - (1 * delta) else if lastBarOfDay then nan else s3;
def r1 = if firstBarOfDay then pp + (.382 * delta) else if lastBarOfDay then nan else r1;
def r2 = if firstBarOfDay then pp + (.618 * delta) else if lastBarOfDay then nan else r2;
def r3 = if firstBarOfDay then pp + (1 * delta) else if lastBarOfDay then nan else r3;

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

https://tos.mx/xPiy57
Can someone add the option to show on expansion yes/no? in addition to have the options to show coefficient left/right and show price left/right. Thank you.

#### Attachments

Can someone add the option to show on expansion yes/no? in addition to have the options to show coefficient left/right and show price left/right. Thank you.

Added Onexpansion option and bubbles with left/right, price and coefficient options

Image shows Onexpansion in upper chart and Display_Left in lower chart

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.
# 20230601 Sleepyz - Added Onexpansion and Bubbles
# ...

declare hide_on_daily;
declare once_per_bar;

input AggregationPeriod = AggregationPeriod.DAY;

#
# logic
#
def nan = Double.NaN;
def isRollover = GetYYYYMMDD() != GetYYYYMMDD();
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def afterEnd = GetTime() > RegularTradingEnd(GetYYYYMMDD());
def firstBarOfDay = if (beforeStart == 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;

input onexpansion = yes;
def pc = close(period = AggregationPeriod);
def ph = high(period = AggregationPeriod);
def pl = low(period = AggregationPeriod);

def pcext = if IsNaN(close) then pcext else pc;
def phext = if IsNaN(close) then phext else ph;
def plext = if IsNaN(close) then plext else pl;

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

plot ppp = if onexpansion and !IsNaN(close) then Double.NaN else pp;
plot ps1 = if onexpansion and !IsNaN(close) then Double.NaN else s1;
plot ps2 = if onexpansion and !IsNaN(close) then Double.NaN else s2;
plot ps3 = if onexpansion and !IsNaN(close) then Double.NaN else s3;
plot pr1 = if onexpansion and !IsNaN(close) then Double.NaN else r1;
plot pr2 = if onexpansion and !IsNaN(close) then Double.NaN else r2;
plot pr3 = if onexpansion and !IsNaN(close) then Double.NaN else 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.CYAN);

input show_bubble = yes;
input show_price  = yes;
input show_coeff  = yes;
input bubble_display = {default right, left, none};

input left_bubblemover = -9;
def   b  = left_bubblemover;
def   b1 = b + 1;

(if show_bubble and !onexpansion
then if bubble_display == bubble_display.left
then if IsNaN(close) then Double.NaN else IsNaN(ppp[b1]) and !IsNaN(ppp[b])
else if bubble_display == bubble_display.right
then lastBarOfDay == 0 and lastBarOfDay[-1] == 1
else Double.NaN
else if show_bubble and onexpansion
then BarNumber() == HighestAll(BarNumber())
else Double.NaN), if bubble_display == bubble_display.right then ppp else ppp[b], "PP" +
if show_price then " " + if bubble_display == bubble_display.right then AsText(ppp) else AsText(ppp[b]) else ""
, ppp.TakeValueColor() );

(if show_bubble and !onexpansion
then if bubble_display == bubble_display.left
then if IsNaN(close) then Double.NaN else IsNaN(ppp[b1]) and !IsNaN(ppp[b])
else if bubble_display == bubble_display.right
then lastBarOfDay == 0 and lastBarOfDay[-1] == 1
else Double.NaN
else if show_bubble and onexpansion
then BarNumber() == HighestAll(BarNumber())
else Double.NaN), if bubble_display == bubble_display.right then ps1 else ps1[b], "S1 " +
(if show_coeff then "-.382" else "") +
if show_price then "\n" + if bubble_display == bubble_display.right then AsText(ps1) else AsText(ps1[b]) else "", ps1.TakeValueColor());

(if show_bubble and !onexpansion
then if bubble_display == bubble_display.left
then if IsNaN(close) then Double.NaN else IsNaN(ppp[b1]) and !IsNaN(ppp[b])
else if bubble_display == bubble_display.right
then lastBarOfDay == 0 and lastBarOfDay[-1] == 1
else Double.NaN
else if show_bubble and onexpansion
then BarNumber() == HighestAll(BarNumber())
else Double.NaN), if bubble_display == bubble_display.right then ps2 else ps2[b], "S2 " +
(if show_coeff then "-.618" else "") +
if show_price then "\n" + if bubble_display == bubble_display.right then AsText(ps2) else AsText(ps2[b]) else "", ps2.TakeValueColor());

(if show_bubble and !onexpansion
then if bubble_display == bubble_display.left
then if IsNaN(close) then Double.NaN else IsNaN(ppp[b1]) and !IsNaN(ppp[b])
else if bubble_display == bubble_display.right
then lastBarOfDay == 0 and lastBarOfDay[-1] == 1
else Double.NaN
else if show_bubble and onexpansion
then BarNumber() == HighestAll(BarNumber())
else Double.NaN), if bubble_display == bubble_display.right then ps3 else ps3[b], "S3 " +
(if show_coeff then "-1.0" else "") +
if show_price then "\n" + if bubble_display == bubble_display.right then AsText(ps3) else AsText(ps3[b]) else "", ps3.TakeValueColor());

(if show_bubble and !onexpansion
then if bubble_display == bubble_display.left
then if IsNaN(close) then Double.NaN else IsNaN(ppp[b1]) and !IsNaN(ppp[b])
else if bubble_display == bubble_display.right
then lastBarOfDay == 0 and lastBarOfDay[-1] == 1
else Double.NaN
else if show_bubble and onexpansion
then BarNumber() == HighestAll(BarNumber())
else Double.NaN), if bubble_display == bubble_display.right then pr1 else pr1[b], "R1 " +
(if show_coeff then ".382" else "") +
if show_price then "\n" + if bubble_display == bubble_display.right then AsText(pr1) else AsText(pr1[b]) else "", pr1.TakeValueColor());

(if show_bubble and !onexpansion
then if bubble_display == bubble_display.left
then if IsNaN(close) then Double.NaN else IsNaN(ppp[b1]) and !IsNaN(ppp[b])
else if bubble_display == bubble_display.right
then lastBarOfDay == 0 and lastBarOfDay[-1] == 1
else Double.NaN
else if show_bubble and onexpansion
then BarNumber() == HighestAll(BarNumber())
else Double.NaN), if bubble_display == bubble_display.right then pr2 else pr2[b], "R2 " +
(if show_coeff then ".618" else "") +
if show_price then "\n" + if bubble_display == bubble_display.right then AsText(pr2) else AsText(pr2[b]) else "", pr2.TakeValueColor());

(if show_bubble and !onexpansion
then if bubble_display == bubble_display.left
then if IsNaN(close) then Double.NaN else IsNaN(ppp[b1]) and !IsNaN(ppp[b])
else if bubble_display == bubble_display.right
then lastBarOfDay == 0 and lastBarOfDay[-1] == 1
else Double.NaN
else if show_bubble and onexpansion
then BarNumber() == HighestAll(BarNumber())
else Double.NaN), if bubble_display == bubble_display.right then pr3 else pr3[b], "R3 " +
(if show_coeff then "1.0" else "") +
if show_price then "\n" + if bubble_display == bubble_display.right then AsText(pr3) else AsText(pr3[b]) else "", pr3.TakeValueColor());

ppp.HideBubble();
ps1.HideBubble();
ps2.HideBubble();
ps3.HideBubble();
pr1.HideBubble();
pr2.HideBubble();
pr3.HideBubble();

#``````

#### Attachments

Added Onexpansion option and bubbles with left/right, price and coefficient options

Image shows Onexpansion in upper chart and Display_Left in lower chart
Hi SleepyZ!
The show on expansion side of this script works perfectly fine and I love it! I just have some additional requests to fix the plots for the non expansion side of the chart if possible.

1. Can you change this so when choosing "show no" on expansion the plots does not go over the expansion side? the plots can stop with the very last candle on the chart. I need to keep the expansion side clean to avoid overlapping studies.

2. Is there anyway possible the coefficient and price info are not a fixed bubble to the left side of the screen when choosing "show values on left" but follows the current chart just like the actual Fibonacci Retracements tool does in TOS?

### Not the exact question you're looking for?

87k+ Posts
224 Online ## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?