Persisting Breakeven and Trailing State Across EA Restarts
Summary
This article extends an MQL5 Expert Advisor’s trade recovery system so dynamic protection can resume after a terminal restart. It explains that restoring a position and its virtual stop alone is insufficient: management also needs to know whether breakeven or trailing has activated and how far trailing had progressed. The proposed design stores those state values in SQLite alongside the updated virtual stop.
Breakeven activates once a configured profit threshold is reached, moves the virtual stop to lock in a small gain, and records that transition to prevent repetition. Trailing begins at its own threshold and advances the stop when price has moved by the configured step, using the last trail price as a reference. The article describes implementation functions and recovery behavior, but the supplied text omits part of the trailing implementation. It provides no backtest or live-trading evidence, and the approach depends on the prior series code and its state persistence architecture.
Key ideas
- Dynamic protection depends on past management decisions, so recovery must restore more than the current virtual stop.
- Breakeven should be recorded as a one-time state transition and saved with the revised stop.
- Trailing progression uses the last price that triggered an update to continue consistently after restart.
- The article describes implementation logic but reports no performance evaluation.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.