Instead of writing a DLL you could also do something like this
if ( it is Friday and 10.30 )
{
CSymbolInfo oSI = NULL ;
oSI.Refresh ( ) ; //This will throw an execption
}
Thanks WPG,
the DLL has been written for other purposes so i've just exploit it's existance.
I've a litte bit modified the code you posted to make it compilable.
( It was reporting this error: 'NULL' - initialize sequence is expected )
CSymbolInfo * oSI;
oSI.Refresh ( ) ; //This throw an execption ( No Object has been created )This works, the EA is forcedly closed by the terminal.
Anyway... is really possible we need to raise an exception to tell the terminal the EA is willing to stop?
Again, thanks
Hi All,
Is there a way for an Expert Advisor to terminate itself?
At the moment i'm using a workaround: since i've written a DLL i've created a function inside wich just throws an Exception.
In this way the terminal blocks the further execution of the EA but don't really terminate it ( and anyway it's not the cleanest way i think ).
Thanks
Best Regards
Gianluca
- www.mql5.com
Thanks Stringo, this is exacly what i was looking for.
I hope this may save some time to others.
Thanks Stringo, this is exacly what i was looking for.
I hope this may save some time to others.
That linked solution is good if you have no intention of ever using the EA again until someone manually goes to the terminal and reloads it on chart. But if you do, couldn't you also just write code to disable EA during certain parts of the day?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi All,
Is there a way for an Expert Advisor to terminate itself?
At the moment i'm using a workaround: since i've written a DLL i've created a function inside wich just throws an Exception.
In this way the terminal blocks the further execution of the EA but don't really terminate it ( and anyway it's not the cleanest way i think ).
Thanks
Best Regards
Gianluca