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 ).
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
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;
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?
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?