Hello,

I am planning to use timeOffset, to determine the previous day's bar at a given time.
Sample:
Code
...
int timezone = CET;
if (lhour(timezone, 0) == 10 && minute(0) == 0){
    int asd = timeOffset(timezone, 1, 5, 0);
    printf("current time: %d %d %d %d\n", month(0), day(0), lhour(timezone, 0), minute(0));
    printf("offset time: %d %d %d %d\n", month(asd), day(asd), lhour(timezone, asd), minute(asd));
    printf("-----------\n");
}


Result:
Code
...
current time: 5 29 10 0
offset time: 5 28 5 0
-----------
current time: 5 30 10 0
offset time: 5 29 5 0
-----------
current time: 5 31 10 0
offset time: 5 30 5 0
-----------
current time: 6 3 10 0
offset time: 5 31 21 45
...


So usually it behaves as it expected:
at 10 AM, with timeOffset I get the previous day's 5AM bar, which is correct.
However at mondays, as you see in the last two lines:
  • I checked at candle 2024-06-03 10:00 AM
  • Expected result: 2024-05-31 05:00 AM
  • Result I got: 2024-05-31 21:45 AM


(If you want to double-check, please keep in mind that it's 2024 data. So in 2025, 06-03 is not monday, but in 2024 it is.)

Do you have any idea why is this wrong? Is it a bug, or I am missing something?

Last edited by NorbertSz; 09/11/25 19:31.