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.