Small change to my EURUSD EA that saved me a few silly trades: after any reconnect to the trade server, the EA waits for one full M1 bar to close before it's allowed to open anything.
Why I added it:
After a reconnect the terminal sometimes backfills a few missed ticks at once. My indicators recalculated on the jump and produced a signal that was never valid in real time.
Spreads right after a reconnect on my VPS were sometimes the stale ones from before the drop, so the spread filter passed when it shouldn't have.
Two of my worst trades in August opened within 5 seconds of a reconnect.
Implementation is simple. In MQL5 I track TerminalInfoInteger(TERMINAL_CONNECTED) on each tick and timer event. When it changes from false to true, I store the current bar time and block new entries until a new bar has opened after that. Open positions are still managed normally.
Since adding it in late August there have been 14 reconnects logged and no trade opened in the blocked window. Obviously I can't prove the trades I skipped would have lost, but the ones before were clearly junk.
Does anyone handle reconnects differently, for example with a fixed number of seconds instead of a bar?
I ran into the same backfill problem on a GBPUSD robot last winter and it took me an embarrassingly long time to figure out why a handful of entries made no sense when I replayed them. The indicators had calculated on a burst of catch-up ticks, exactly like you describe, and the signal only existed for a split second that never really happened in live trading.
I went with a time-based block instead of waiting for a bar, mainly because my EA works off M5 and waiting up to five minutes felt like too much. After the connected flag flips back, I hold entries for 45 seconds and also require that the current spread has been updated by at least three fresh ticks. That second check is the one that actually stopped the stale spread issue for me.
Your bar approach is cleaner on M1 though. One thing worth logging is reconnects that happen in the middle of an open trade, because I found my trailing stop logic also misbehaved on the backfill and nudged a stop on a price that was never tradable.