Is there a way to get the close X years ago and use it in calculations on the current bar, that doesn't involve looping backwards X years?
EDIT:
For example, I would like to do the following:
plot(close[1Y])
plot(close[2Y])
The following does not work, due to unknown closed days in each market and leap years:
plot(close[365])
plot(close[730])
The only way I have been able to figure this out is to use a loop which is extremely inefficient especially once you start considering more than a few years into the past.