#Auto Fib Levels After Bar @rangeEnd Closes
#Using Mobius' OR logic for Range
#Plots limited to RTHrs
input rangeStart = 0930;
input rangeEnd = 0935;
input ShowTodayOnly = no;
def A = if SecondsTillTime(rangeEnd) > 0 and SecondsFromTime(rangeStart) >= 0
then 1
else 0;
def today = if ShowTodayOnly == no or
GetDay() == GetLastDay() and SecondsFromTime(rangeStart) >= 0
then 1
else 0;
def H = if H[1] == 0 or
A[1] == 0 and A == 1
then high
else if A and high > H[1]
then high
else H[1];
def L = if L[1] == 0 or
A[1] == 0 and A == 1
then low
else if A and low < L[1]
then low
else L[1];
def Range = H - L;
def HA = if A or today < 1
then Double.NaN
else H;
def LA = if A or today < 1
then Double.NaN
else L;
plot f382 = if SecondsFromTime(1600)[1] >= 0 or
(SecondsFromTime(0000) > 0 and SecondsFromTime(rangeStart) < 0)
then Double.NaN
else LA + Range * .382;
plot f618 = if SecondsFromTime(1600)[1] >= 0 or
(SecondsFromTime(0000) > 0 and SecondsFromTime(rangeStart) < 0)
then Double.NaN
else LA + Range * .618;
f382.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
f618.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
input bubble = yes;
input bubblemover = 3;
def b = bubblemover;
def b1 = b + 1;
AddChartBubble(bubble and IsNaN(f382[b]) and !IsNaN(f382[b1]), f382[b1], "38.2%\n" + AsDollars(f382[b1]), f382.TakeValueColor());
AddChartBubble(bubble and IsNaN(f618[b]) and !IsNaN(f618[b1]), f618[b1], "61.8%\n" + AsDollars(f618[b1]), f618.TakeValueColor());
#