I would make a bi dimensional array (or 2 arrays, one for X position and one for Y position). Every tick, push front the current X and Y position into the array. If you need to go back 5 seconds in the past, then you'll have 300 (60 tick per second * 5) entries in each array.
Every tick, delete entries at index > 299 (if you don't need to recall farther than 5 seconds)
When the ability is used, just load the values at 299 if they exist, or the highest index values if they don't (which means the player didn't played for 5 seconds yet). You probably have to empty the arrays, too.
If you're unfamiliar with arrays, I strongly recommend reading this : https://www.scirra.com/tutorials/307/ar ... ers/page-1
Hope it helps! Good luck!