How to - EA end itself

 

I'm working with an EA for testing a series of functions, but I only want it to work one trade with each execution right now. How would I have the ea automatically end itself? I tried calling deinit() from start, but that didn't work. Is there a way to do this?

Thanks in advance.

Nick

 
bool Stop = false;
 
int start()
{
    if (Stop)
        return (0);
 
    OrderSend(...);
    if (IsTesting())
    {
        Stop = true;
        return(0);
    )
}
Flag Stop prevents any further execution even though the tester doesn't stop and continues idling.
 
Irtron:
bool Stop = false;
 
int start()
{
    if (Stop)
        return (0);
 
    OrderSend(...);
    if (IsTesting())
    {
        Stop = true;
        return(0);
    )
}
Flag Stop prevents any further execution even though the tester doesn't stop and continues idling.

Thanks.  I've should've realized it was that simple.
 

This approach does not remove the EA from the chart, though. Is there a way to do that...and force the deinit() function to run?

 
If you want to unload, than script is better, but it has to be loop with Sleep(xx_seconds*1000) between cycles of functions until order is sent, than should break the loop in function.

how would look like:
extern int sleep_seconds = 5;
int start() 
 {
  orderTicket=-1;
  while(orderTicket<0) // loop function until order is filed
   {
    // performing check functions and Order
    Sleep(sleep_seconds*1000); // pause the script to avoid 100% cpu occupancy
   }
  return(0);
 }
 
thank u very much
Reason: