An EA that restarts, after a VPS reboot or a platform update, needs to know what it already did. Otherwise it can open a duplicate position.
Common causes of duplicates:
The EA uses an internal variable to remember "trade open", which resets to false on restart.
A signal is still valid after the restart, so the EA acts on it again.
Two terminals run the same EA on the same account after a recovery.
Solutions:
On start, scan open positions and pending orders by magic number and symbol, and rebuild the internal state from them.
Store the time of the last signal acted on in a global variable of the terminal or a file, and refuse to act on the same signal twice.
Use a lock file or a global variable with the terminal ID, so a second instance knows it's not alone.
Testing: restart the terminal on purpose on a demo account while a position is open, and in the middle of a signal bar. Check the log for duplicate actions.
This is one of those features nobody notices until it fails.
FXS London Scalper wrote: Sun Nov 01, 2026 1:53 pm
An EA that restarts, after a VPS reboot or a platform update, needs to know what it already did. Otherwise it can open a duplicate position.
Common causes of duplicates:
The EA uses an internal variable to remember "trade open", which resets to false on restart.
A signal is still valid after the restart, so the EA acts on it again.
Two terminals run the same EA on the same account after a recovery.
Solutions:
On start, scan open positions and pending orders by magic number and symbol, and rebuild the internal state from them.
Store the time of the last signal acted on in a global variable of the terminal or a file, and refuse to act on the same signal twice.
Use a lock file or a global variable with the terminal ID, so a second instance knows it's not alone.
Testing: restart the terminal on purpose on a demo account while a position is open, and in the middle of a signal bar. Check the log for duplicate actions.
This is one of those features nobody notices until it fails.
How do you handle restarts in your EAs?
Hi,
you are right, this is very common issue of all newbie EA traders.
I had same issue years ago too. IT was little bit surprise.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.