Put the files here :
Include\Schedule\Schedule.mqh
Scripts\Tests\Schedule\ScheduleTests.mq4
Include the Schedule file in your project and wire it up to the user inputs. The schedule object will have a method for checking whether a time is within the active schedule or not. The tests scripts should show the intended functionality.
#include <Schedule\Schedule.mqh>
// setting up values to define the schedule
ENUM_DAY_OF_WEEK StartDay=1;//Start Day
ENUM_DAY_OF_WEEK EndDay=5;//End Day
string StartTime="12:30";//Start Time
string EndTime="14:30";//End Time
// Creating the schedule from above settings
Schedule s(StartDay,StartTime,EndDay,EndTime);
// Displaying the schedule as a string in English
Print("Schedule : ",s.ToString());
// Creating a datetime to check, this would normally come from ticks or bars instead.
datetime ted0 = StrToTime(StringConcatenate("2018.06.10 ", (string)(s.TimeEnd.Hour), ":", (string)(s.TimeEnd.Minute)));
// Checking whether the given datetime falls within the schedules active time.
Print(s.IsActive(ted0));
I don’t think I tested it where the beginning and ending day of the week are the same value. Let me know if you use it and it works.