Kill EA if TimeCurrent is greater than a defined Date

 

Hi,

I'm trying to stop the EA if the TimeCurrent is greater than a defined Date1. The program is working fine IF the two date are different, But once the dates are identical and the difference is only in time, it's not working (eg: TimeCurrent is: 2021.01.24 01:47 and Defined date is: 2021.01.24 00:15). Here is my code:

datetime Date1 = D'2021.01.24 00:15';

void DateChecker (){
   
   if(TimeCurrent() > Date1){
      ExpertRemove();
      }
} 

int OnInit() {

   EventSetTimer(60);
   DateChecker();
//...
}

int deinit() {
   //.....   
  EventKillTimer();
}

void OnTimer(){
    DateChecker();
}

What's wrong with this code?

 

What time is showing in the market watch window? 

That should give you a clue.

If your broker has no new incoming ticks at the weekend, TimeCurrent() will stay at Friday close time until Monday.

 
Keith Watford:

What time is showing in the market watch window? 

That should give you a clue.

If your broker has no new incoming ticks at the weekend, TimeCurrent() will stay at Friday close time until Monday.

Thank you for your answer, that was the problem
Reason: