Solution for previous day's hour and minute bar:
Code
int getBarFromPreviousDay(int h, int m, int tz = UTC){
    const int currentDay = day(0);
    for (int i = 1; i <= LookBack; i++) {
        if (day(i) == currentDay) continue;
        if (lhour(tz, i) == h && minute(i) == m) return i;
    }
    printf("No bar found for previous day at %02d:%02d within LookBack period.\n", h, m);
    return -1;
}

Last edited by NorbertSz; 09/13/25 11:54.