An EA sends a buy, the call times out, the code retries, and the position count ends up at three. The log shows one signal. The account shows a tripled risk.
The mechanism is simple. A timeout or a generic error on the client side does not mean the server rejected the order. Quite often the order was accepted and the confirmation simply never arrived or arrived late. A retry loop that assumes failure means the first order is still alive when the second goes out. A reconnect can produce the same thing: the EA reinitialises, loses its memory of what it already sent, sees the same signal on the current bar and sends again.
Fixes that work in practice:
- Before any retry, scan open positions, pending orders and recent history for the same magic number, symbol and a unique signal ID in the comment.
- Limit retries to one or two, with a fresh price check each time.
- Never retry blindly on errors where the market has moved, such as requotes, with the old price.
- Store the last signal time in a global variable or file, so a restart does not forget it.
To test it, cut the network right after the send on a demo account and watch what the EA does when the connection returns.
What is the retry rule in use after a timeout: check state first, or never retry automatically?
Why one signal turned into three positions
-
Amanhasnoname
- Posts: 1506
- Joined: Fri Oct 30, 2026 9:45 am