I have an EA running on demo and real at the same broker and yesterday, saw something for the first time with this EA that bothered me. On demo, the EA opened 2 simultaneous buys at the same time (up to sub-second), which forced an equity close unexpectedly. However, on the real server, it traded one trade at the same minute, without the duplication.
My question is: what could cause this? Since I have an order count feature, it could only happen if somehow the server hiccups or my connection hiccups at the exact same ms that that order is sent and then repeats.
How can I avoid this? I was thinking of using "Sleep()" but don't like it, because it stops the EA completely for that amount of time, but since I would only sleep for a millisecond or two at most, it would probably alleviate the issue. But the real reason I don't like to use the sleep function is that it can not be tested with the MT4 tester since it's ignored by the tester.
I know this has been asked before, but there has not been any alternatives offered....What other options do I have instead of Sleep(), to delay an EA for a few milliseconds and be able to test it?
My question is: what could cause this? Since I have an order count feature, it could only happen if somehow the server hiccups or my connection hiccups at the exact same ms that that order is sent and then repeats.
How can I avoid this? I was thinking of using "Sleep()" but don't like it, because it stops the EA completely for that amount of time, but since I would only sleep for a millisecond or two at most, it would probably alleviate the issue. But the real reason I don't like to use the sleep function is that it can not be tested with the MT4 tester since it's ignored by the tester.
I know this has been asked before, but there has not been any alternatives offered....What other options do I have instead of Sleep(), to delay an EA for a few milliseconds and be able to test it?