int OnInit()
{
if(!expirationdate())
{
Alert("Expired!!!");
return(INIT_FAILED);
}
}
{
if(!expirationdate())
{
Alert("Expired!!!");
return(INIT_FAILED);
}
}
James Cater:
int OnInit()
{
if(!expirationdate())
{
Alert("Expired!!!");
return(INIT_FAILED);
}
}
{
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).
Thanks a million.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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:
{
//---
if(expirationdate() !=true)
{
Alert("Expired!!!");
return(0);
}
}
I wrote the function:
{// 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.