Overlay previous 2 days of data


New member
Hello - is there someone who can create an indicator that overlays price action from yesterday's and 2 days ago?


New member
yes - something like this for gold:

Last edited by a moderator:


Well-known member
It could probably be done, though it might get kinda funky. I've got a script around here somewhere that gives average volume by time for the previous day. You could start with that and modify the series to be CLOSE rather than VOLUME. In an ideal world, you could get it to separate days using some convoluted combination of today's date and previous days (getDate maybe?).

You can also build yourself a lower indicator for your markets open/closed using secondsTill() and secondsFrom() if you need.

Happy Trading,


Well-known member
FIRST: You will have to set the aggregation period in the study to match your chart.
SECOND: use the DISPLACE feature in the study to shift it over (you pretty much count how many bars are in each day and set it at that number)
takes a little bit of work but it works. Not sure what its worth to you, but in about 5 mins you should be able to adjust to your liking.

input aggregationPeriod = AggregationPeriod.DAY;
input length = 1;
input displace = -1;
input showOnlyLastPeriod = no;
plot PrevDayClose;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) { PrevDayClose = Double.NaN;
} else { PrevDayClose = Highest(close(period = aggregationPeriod)[-displace], length);


Well-known member
i was pretty bored.. 2hrs later here you go what you requested:
Its Price Comparison From Previous Day at the same bar (or same time )and can be adjusted to compare XZY days ago by adjusting the "DaysAgo"

remember to hit the like button if you liked my post!


#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.SetDefaultColor(CreateColor(0, 255, 255));
plot Current_Price = c;
Current_Price.SetDefaultColor(CreateColor(0, 191, 0));

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
Last edited:

Similar threads