Prevent code from Calling OnTick()

 

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.


 

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

 
James Cater:

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


Thanks a million.
 
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).