Discussing the article: "Engineering a Self-Healing Expert Advisor in MQL5 (Part 2): Restart-Safe Virtual Trade Protection"
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: Engineering a Self-Healing Expert Advisor in MQL5 (Part 2): Restart-Safe Virtual Trade Protection.
Build a restart-aware virtual protection layer on top of the SQLite persistence from Part 1. The EA reconstructs hidden stop-loss and take-profit after restart, verifies current price against recovered exits, and closes or continues positions accordingly. The result is a consistent recovery path that detects managed positions and sustains safe runtime management.
In a virtual protection system, the stop-loss and take-profit levels exist only inside the runtime memory of the Expert Advisor. The EA continuously monitors market prices during execution and manually closes positions whenever the virtual protection conditions are reached.
Under normal runtime conditions, this architecture functions correctly. However, the situation changes immediately once the trading terminal shuts down unexpectedly. Consider the following scenario:
This problem occurs because the runtime memory is volatile. Once the terminal closes, the Expert Advisor loses access to its internal protection state and stops monitoring the active position completely.
During this offline period, the market continues moving normally. If price crosses the hidden stop-loss while the Expert Advisor is no longer running, the broker remains unaware because no broker-side stop-loss was ever placed. After a restart, the trade may still remain open even though the intended protection conditions were already violated earlier.
Author: Chacha Ian Maroa