Not completely free of time interval, but you can just use
system.tag.queryTagHistory() with the returnSize set to 5. So long as you have recorded 5 events with in an interval you’ll get the Top 5 records returned.
#returns the top 5 records within the last 8 hours
ds0 = system.tag.queryTagHistory(tagPaths,returnSize=5, noInterpolation = True)
#returns the top 5 records within the last day
ds1 = system.tag.queryTagHistory(tagPaths, system.date.addDays(system.date.now(),-1),returnSize = 5, noInterpolation = True)
Note, use noInterpolation to insure you only get real values.
I know it isn’t exactly what you were looking for, but at some point if a value hasn’t changed in x amount of time it really becomes irrelevant. I would suggest setting the Max Time between records in the historical settings to insure that you record the value at least once for that interval.