Seeking help to identify Custom(FxSession) new day
Seems found partial solution
//+-------------------------------------------------------------------------------------------------------------------------+ //| FxSession element[0] represent current Day's session times //| CPRSession element[0] calculated for previous FxSession[1] | We shall retain data only for forex session with 'mSessionID' //+-------------------------------------------------------------------------------------------------------------------------+ ArrayResize(CPRSession,ArrayRange(vFxSession,0)-1); for(int day = ArrayRange(vFxSession,0)-2; day >= 0; day--) { if(mSessionID == NYC) { if(day != 0) { CPRSession[day].Begin = vFxSession[1+day][NYC].Begin; CPRSession[day].End = vFxSession[day][NYC].Begin - 60; } // Current day's NYC session not yet started (FxSession stores datetime value as '0' Zero = 1970.01.01 00:00:00) if(day == 0) { if(TimeCurrent() > vFxSession[1+day][NYC].Begin && vFxSession[day][NYC].Begin == StringToTime("1970.01.01 00:00:00")) { CPRSession[day].Begin = vFxSession[1+day][NYC].Begin; CPRSession[day].End = vFxSession[1+day][NYC].Begin + PeriodSeconds(PERIOD_D1) - 60; } // Current day's NYC session just started on current bar if(TimeCurrent() == vFxSession[day][NYC].Begin) { CPRSession[day].Begin = vFxSession[day][NYC].Begin; CPRSession[day].End = vFxSession[day][NYC].Begin + PeriodSeconds(PERIOD_D1) - 60; } } } } ArrayPrint(CPRSession); /* 2024.05.23 12:37:04.568 2024.05.01 01:01:20 [Begin] [End] 2024.05.23 12:37:04.568 2024.05.01 01:01:20 [0] 2024.04.30 15:00:00 2024.05.01 14:59:00 at Beginning of Broker's Day 2024.05.23 12:37:04.568 2024.05.01 01:01:20 [1] 2024.04.29 15:00:00 2024.04.30 14:59:00 2024.05.23 12:37:04.568 2024.05.01 01:01:20 [2] 2024.04.26 15:00:00 2024.04.29 14:59:00 2024.05.23 12:37:04.568 2024.05.01 01:01:20 [3] 2024.04.25 15:00:00 2024.04.26 14:59:00 2024.05.23 12:37:04.568 2024.05.01 01:01:20 [4] 2024.04.24 15:00:00 2024.04.25 14:59:00 2024.05.23 12:37:39.911 2024.05.01 14:00:00 [Begin] [End] 2024.05.23 12:37:39.911 2024.05.01 14:00:00 [0] 2024.04.30 15:00:00 2024.05.01 14:59:00 at PeriodH01 bar before NYC Session start 2024.05.23 12:37:39.911 2024.05.01 14:00:00 [1] 2024.04.29 15:00:00 2024.04.30 14:59:00 2024.05.23 12:37:39.911 2024.05.01 14:00:00 [2] 2024.04.26 15:00:00 2024.04.29 14:59:00 2024.05.23 12:37:39.911 2024.05.01 14:00:00 [3] 2024.04.25 15:00:00 2024.04.26 14:59:00 2024.05.23 12:37:39.911 2024.05.01 14:00:00 [4] 2024.04.24 15:00:00 2024.04.25 14:59:00 2024.05.23 12:37:40.804 2024.05.01 15:00:00 [Begin] [End] 2024.05.23 12:37:40.804 2024.05.01 15:00:00 [0] 2024.05.01 15:00:00 2024.05.02 14:59:00 at NYC Session start in Broker's Server time 2024.05.23 12:37:40.804 2024.05.01 15:00:00 [1] 2024.04.29 15:00:00 2024.04.30 14:59:00 should be 2024.04.30 to 2024.05.01 2024.05.23 12:37:40.804 2024.05.01 15:00:00 [2] 2024.04.26 15:00:00 2024.04.29 14:59:00 should be 2024.04.29 to 2024.04.30 2024.05.23 12:37:40.804 2024.05.01 15:00:00 [3] 2024.04.25 15:00:00 2024.04.26 14:59:00 should be 2024.04.26 to 2024.04.29 ... WeekEnd 2024.05.23 12:37:40.804 2024.05.01 15:00:00 [4] 2024.04.24 15:00:00 2024.04.25 14:59:00 should be 2024.04.25 to 2024.05.26 */
Goal to get new specified Forex Session start-end times in CPRSession[] ... (Code in 'bold' letters)
ForexSession are calculated and populated in cFxSession[day][sessionID] and arrayprint used to display calculated values.
CPRSession[] is created to get particular sessionID start-end times (Broker Server) for given number of days. e.g. NYC start 15:00 and NYC stop next day 14:59 Hrs
All times printed in code are Broker's sever time
Thanks in advance for all gurus here for their support and resolving the puzzle.
Regards.