You’d just need to maintain your own index and use the P or PN command. e.g.
X WRAP ADD 1 X 1 3
TR 1 PN 0 X
Y WRAP ADD 1 Y 8 21
TR 2 PN 0 X
If you don’t want to use a variable up, you could also save the index in a pattern location, similarly you could also save the start and ends of the loops in pattern locations, especially as patterns are easy to edit ‘live’.
Is that what you’re after?
(as an aside, one of the things I’d like to contribute at some point are PN.xxx versions of all of the P.xxx commands, e.g. PN.POP 0 will pop a value from pattern 0)