#Auto_FibPrevDay - plots high/low from previous day and fib levels based thereon
input ShowTodayOnly = yes;
input showbubbles = yes;
input bubblemover = 4; #Hint n: Number of Bars to shift bubble to the right
input period = AggregationPeriod.DAY;
input displace = 1;
plot ORH = if showtodayonly and !IsNaN(close(period = period)[-1]) then double.nan else high(period = period)[displace];
plot ORL = if showtodayonly and !IsNaN(close(period = period)[-1]) then double.nan else low(period = period)[displace];
ORH.SetDefaultColor(Color.RED);
ORH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ORH.SetLineWeight(2);
ORL.SetDefaultColor(Color.GREEN);
ORL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ORL.SetLineWeight(2);
input F1 = -1.00;
input F2 = -0.62;
input F3 = -0.27;
input F4 = 0.236;
input F5 = 0.382;
input F6 = 0.500;
input F7 = 0.618;
input F8 = 0.764;
input F10 = 1.27;
input F11 = 1.618;
input F12 = 2.00;
def rHi = ORH;
def rLo = ORL;
def range = rHi - rLo;
plot FF1 = rLo + (range * F1);
plot FF2 = rLo + (range * F2);
plot FF3 = rLo + (range * F3);
plot FF4 = rLo + (range * F4);
plot FF5 = rLo + (range * F5);
plot FF6 = rLo + (range * F6);
plot FF7 = rLo + (range * F7);
plot FF8 = rLo + (range * F8);
plot FF10 = rLo + (range * F10);
plot FF11 = rLo + (range * F11);
plot FF12 = rLo + (range * F12);
def h = high(period = AggregationPeriod.DAY);
def l = low(period = AggregationPeriod.DAY);
FF1.SetDefaultColor(Color.GREEN);
FF1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF1.SetLineWeight(1);
FF2.SetDefaultColor(Color.GREEN);
FF2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF2.SetLineWeight(1);
FF3.SetDefaultColor(Color.GREEN);
FF3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF3.SetLineWeight(1);
FF4.SetDefaultColor(Color.RED);
FF4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF4.SetLineWeight(1);
FF5.SetDefaultColor(Color.RED);
FF5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF5.SetLineWeight(1);
FF6.SetDefaultColor(Color.YELLOW);
FF6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF6.SetLineWeight(1);
FF7.SetDefaultColor(Color.cyan);
FF7.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF7.SetLineWeight(1);
FF8.SetDefaultColor(Color.cyan);
FF8.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF8.SetLineWeight(1);
FF10.SetDefaultColor(Color.GREEN);
FF10.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF10.SetLineWeight(1);
FF11.SetDefaultColor(Color.GREEN);
FF11.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF11.SetLineWeight(1);
FF12.SetDefaultColor(Color.GREEN);
FF12.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF12.SetLineWeight(1);
def b = bubblemover;
def b1 = b + 1;
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF1[b], F1, FF1.Takevaluecolor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF2[b], F2, FF2.Takevaluecolor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF3[b], F3, FF3.Takevaluecolor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF4[b], F4, FF4.Takevaluecolor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF5[b], F5, FF5.Takevaluecolor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF6[b], F6, FF6.Takevaluecolor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF7[b], F7, FF7.Takevaluecolor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF8[b], F8, FF8.Takevaluecolor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF10[b], F10, FF10.Takevaluecolor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF11[b], F11, FF11.Takevaluecolor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF12[b], F12, FF12.Takevaluecolor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), orh[b], 1, orh.Takevaluecolor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), orl[b], 0, orl.Takevaluecolor());