#Price Comparison From Previous Day at the same bar
input DaysAgo = 1;
def c = close;
def x = BarNumber();
def nan = double.nan;
def RTHbar1 = if getday()<>getday()[Daysago]
then x
else RTHbar1[1];
def PrevRTHbar1 = if RTHbar1 != RTHbar1[1]
then RTHbar1[1]
else PrevRTHbar1[1];
def indexBar = RTHbar1 - PrevRTHbar1;
plot PrevDay = if IsNaN(c)
then nan
else GetValue(c, indexBar);
PrevDay.SetPaintingStrategy(PaintingStrategy.LINE);
PrevDay.SetDefaultColor(CreateColor(0, 255, 255));
PrevDay.SetLineWeight(1);
plot Current_Price = c;
Current_Price.SetPaintingStrategy(PaintingStrategy.LINE);
Current_Price.SetDefaultColor(CreateColor(0, 191, 0));
Current_Price.SetLineWeight(1);
AddLabel(1, "Same Bar Comparison from " + DaysAgo + " Days ago " + PrevDay , PrevDay.TakeValueColor());
AddLabel(1, "Current Price = " + Current_Price , Current_Price.TakeValueColor());
#END Price Comparison From Previous Day at the same bar