Download MetaTrader 5

Prevent code from Calling OnTick()

To add comments, please log in or register
Morteza Khorasani
131
Morteza Khorasani  

I want to add the expiry check in the OnInit() section and if returns false , I want to prevent it from going ahead. And I want to stop the code.

‌‌I have written this:

int OnInit()
  {
//---
if(expirationdate() !=true)
{
Alert("Expired!!!");
return(0);
}

}

‌I wrote the function:

bool expirationdate()
{// function expiry check
if(TimeCurrent()>Expiry_DateTime)
return(false);
else return(true);
}// function expiry check

But When it shows the alert it will continue to the OnTick() and continue the code.

I want to stop thecode from running.


Blahtech Limited
6858
James Cater  

int OnInit()
{
   if(!expirationdate())
   {
      Alert("Expired!!!");
      return(INIT_FAILED);
   }
}

Morteza Khorasani
131
Morteza Khorasani  
James Cater:

int OnInit()
{
   if(!expirationdate())
   {
      Alert("Expired!!!");
      return(INIT_FAILED);
   }
}


Thanks a million.
Alain Verleyen
Moderator
35039
Alain Verleyen  
Morteza Khorasani:

Thanks a million.
However if your indicator is already running when the expiration date is reached, it will continue to work...possible for months (not joking I have seen it :-D).
To add comments, please log in or register