how to end script from terminal

 
Hello,
i like to have script which contains a loop in the main function:

while(myCondition=false)
{
Sleep(2000);
}

in deinit i set
myCondition=true;

But when trying to "delete" from Chart, this script is still running.
Anyone has an idea ?
thank you
 

Init start and deinit are functions so my reasoning says put a return(0) ; to exit the Start function

Be interested to see what the experienced have to say.

 

Where have you define the variable "myCondition" ? it must be the same for DEINIT and START()

 
Matutin:

Where have you define the variable "myCondition" ? it must be the same for DEINIT and START()

myCondition is global for script, so same scope in init,start,deinit.

my start function of course returns (0);

the problem is: the start function runs, until myCondition=true.

So when deleting from chart, i need a call into script in order to set myCondition.

(all this would be no problem, if could detach EA from within EA).

 
Matutin:

Where have you define the variable "myCondition" ? it must be the same for DEINIT and START()

the simplified code:


bool finished=false;
int deinit()
{
finished=true;
return(0);
}
int start()
{
while(finished == false)
{
Sleep(2000);
}

return(0);
}
 

Be tempted to have a controling EA that creates or destroys other EA's as objects. Effecency would be poor though.

 
hurgax:
[...] But when trying to "delete" from Chart, this script is still running.
Anyone has an idea ?

If I understand what you're doing here, then you should simply be using IsStopped() - e.g. while(!IsStopped()) { ... }

 
jjc:

If I understand what you're doing here, then you should simply be using IsStopped() - e.g. while(!IsStopped()) { ... }


thank you, that was what i looked for.

while(finished == false && IsStopped() == false)
{
Sleep(2000);
}
Reason: