📅  最后修改于: 2022-03-11 15:00:15.829000             🧑  作者: Mango
//--- input parameters
//--- Time Parameters
bool InpTimeControl = true; // Use time control
input uchar InpStartHour = 1; // Start hour
input uchar InpEndHour = 23; // End hour
//--- Time Control
if(TimeControl())
{
}
//+------------------------------------------------------------------+
//| TimeControl |
//+------------------------------------------------------------------+
bool TimeControl(void)
{
if(!InpTimeControl)
return(true);
MqlDateTime STimeCurrent;
datetime time_current=TimeCurrent();
if(time_current==D'1970.01.01 00:00')
return(false);
TimeToStruct(time_current,STimeCurrent);
if(InpStartHour=InpStartHour && STimeCurrent.hourInpEndHour) // time interval with the transition in a day
{
/*
Example:
input uchar InpStartHour = 10; // Start hour
input uchar InpEndHour = 5; // End hour
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
_ _ _ _ _ _ _ _ _ _ + + + + + + + + + + + + + + + + + + + _ _ _ _ _ + + + + + +
*/
if(STimeCurrent.hour>=InpStartHour || STimeCurrent.hour