This piece of code here doesn't seem to be working. - page 2

 
MetaNt:
Seems to be working now, however after 5 bars the shift goes from 5 to 16...
Is OOTB a bar start time ? us iBarShift() to convert your time to a bar number . . .
 

Ah, how silly of me, I will try that.

That has fixed it! Thank you very much.