RobotFX curates the best open-source MetaTrader code to inspire your trading automation.
Restart-Safe EA Template is a clean Expert Advisor skeleton that shows execution practices many EAs miss. The most common problem it solves: after MetaTrader or the VPS restarts, the EA sees the same signal again and opens a duplicate trade.
- Signals are evaluated only on closed bars and only once per bar.
- The last processed bar is stored in a terminal global variable, so a restart never repeats a signal.
- One position per symbol and magic number, recognised again after a restart.
- Spread filter, broker stop-level check and volume normalisation.
- Every decision (entry sent, signal skipped and why, broker retcode) is written to the Experts log.
The included signal is a simple moving-average cross for demonstration only: replace the GetSignal() function with your own rules. This is an educational template, not a profitable strategy. Suggested for testing: EURUSD M15.
Inputs
Smooth out market noise with the Heiken Ashi Expert Advisor for MT4 and MT5. Reliable trend-following automation. Details here.
- Fast and slow MA periods and MA method (demo signal).
- Lot size, stop loss and take profit in points (0 = none).
- Maximum spread in points, magic number and maximum deviation.
Screenshot: Experts log in the Strategy Tester showing entries and skipped signals with their reason.

Level up your trading with professional RobotFX expert advisors and indicators. Visit robotfx.org for proven MT4/MT5 tools.
78715