Hi-
I am using intraday data and would like to be able to get the price from the exact same time of day as the current bar but from x days ago. I tried to accomplish this with ValueWhen() but I can't think of a way to set the current bar time constant. Can anyone help?
x=2;
CurrBarTime = TimeNum();
ValAtTime = ValueWhen(TimeNum() == CurrBarTime,C,X);
...obviously the CurrBarTime just continues to roll back along with the ValueWhen function.
Also, if I can get this to work, I am likely to come across a scenario where there is no bar available for exactly same time on previous days. In that instance I'd like to take the next closest bar...would also appreciate any thoughts on how to do that..
Thank you.