Discussing the article: "Using the MQL5 Economic Calendar for News Filter (Part 3): Surviving Terminal Restarts During News Window"
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: Using the MQL5 Economic Calendar for News Filter (Part 3): Surviving Terminal Restarts During News Window.
The article introduces a restart-safe storage model for news-time stop removal. Suspension state and original SL/TP per position are written to terminal global variables, reconstructed on OnInit, and cleaned after restoration. This lets the EA resume an active suspension window after recompiles or restarts and restore stops only when the news window ends.
We already have a news filter that temporarily removes SL/TP and restores them after a news window in Part 2 of this series. The existing implementation, however, keeps its state only in memory: savedStops[] and the newsSuspended flag. If a restart or recompile occurs between SuspendStops(true) and SuspendStops(false), that in-memory state is lost. The EA no longer identify which positions had their stops removed. The result: open positions may remain unprotected or never be restored, and without a recovery mechanism, the system cannot safely reconstruct its previous state.
To address this, we define a recovery contract. The system must persist trade state externally: ticket IDs, stop levels, and suspension status. Upon reinitialization, this data must be restored accurately, ensuring that the system resumes operation without prematurely restoring stops or leaving trades unprotected.
This article implements a persistent state layer using global variables of the terminal, ensuring that the system maintains continuity across interruptions and behaves deterministically under all restart conditions.
Author: Solomon Anietie Sunday