Trouble collecting day open equity

 

Hi all,

I am trying to collect the day open equity so I can control my daily drawdown and close all trade if it gets reached. However I don't understand why it is not working. Here is the following code I am testing: 

double EquityOpenDay; 

int OnInit()
  {
   EventSetTimer(15); 
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
   EventKillTimer();
  }
  

void OnTimer(){
   datetime time = TimeCurrent();
   CurrentTime = TimeToString(time, TIME_MINTUTES); 

   if(CurrentTime == "00:00" ){
      EquityOpenDay = AccountInfoDouble(ACCOUNT_EQUITY);  
      Print("day open equity " , EquityOpenDay); }

}

The Print statement gets executed every 15 seconds from 00:00:00 until 00:14:45. I don't understand why the condition CurrentTime == "00:00" is true during 15 minutes and not only 1 minute. 

Please help. And if you a more efficient to collect day open equity I am interested also. 

Thanks 

 
Raphael A: I don't understand why the condition CurrentTime == "00:00" is true during 15 minutes and not only 1 minute. 

Maybe because the broker has markets closed during the first 15 mins of the 0:00 hour, so please check the Market schedule for the broker and symbol.

The CurrentTime function returns the trade server time, and if there is no activity and no ticks coming in, then the server time is not updated.

 
Fernando Carreiro #:

Maybe because the broker has markets closed during the first 15 mins of the 0:00 hour, so please check the Market schedule for the broker and symbol.

The CurrentTime function returns the trade server time, and if there is no activity and no ticks coming in, then the server time is not updated.

Thank you, TimeLocal does the job