Hi Tradegiel
1. The sleep here is try to run the logic that I put inside the while loop in a fix interval, I need it is because EA is run only when there is new tick. For some reason I need to run some logic regularly .
2. Did u mean that when you stopped the EA ( here I mean you press the Expert Advisor button from the top menu bar, the smiley face of the EA becomes a Cross), then, you no longer see the print function running?
Thanks for your helping
Best Regards
Tom
"I cannot imagine that this code causes trouble. I mean, I don't know why you use Sleep()..."
...
Sleep() gives processing time to other code..
Endless loop with no Sleep() = 100% cpu, and MT4 "locks up".
Run the code above, omitting the Sleep().
phy,
MT4 "locks up"
? is there interrupt hot key combination that terminal can see...?
eg: CTRL-BREAK or CTRL-C
have always wondered... thanks
None that I know of. If the X button to close the app doesn't work, kill terminal.exe with TaskManager.
Been there done that.
Yes, very un-graceful departure indeed. thanks
Hi Phy
If I have to remove the sleep() function inside the while loop, it will run continuously which defeat my purpose to run this loop in a fix interval.. What I don't understand here is the while statement should examine the IsStopped() to decide whether the loop should continue and I expect IsStopped() will return false when I deactivate the EA
Regards
Tom

- 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
I try to put a small looping rountine into my EA, below is the testing code
int start()
{
//----
while(IsStopped() == false)
{
Print("1");
Print("2");
Print("3");
Sleep(5000);
}
//----
return(0);
}
My problem is IsStopped is always false even I deactivate the EA from the chart, I still can see the Print() function are running continuously . Even though the MQL4 help topic mentions that the IsStopeed() returns TRUE if the program (an expert or a script) has been commanded to stop its operation, otherwise returns FALSE. But I can't see it work in my testing code.
Anyone knows what could be wrong
Best Regards
Tom