Discussing the article: "Interactive Supply and Demand Zone Manager in MQL5 (Part V): Persisting Zones Across Terminal and EA Restarts"

Check out the new article: Interactive Supply and Demand Zone Manager in MQL5 (Part V): Persisting Zones Across Terminal and EA Restarts.

We introduce a versioned persistence layer that saves and restores the zone engine's logical state across sessions. The snapshot preserves lifecycle status, interaction history, scores, blacklist prices, and the geometry and time anchors of user‑drawn rectangles, and it is reconstructed and reconciled with chart objects on startup. User zones enter with the minimum score so they integrate into the same lifecycle and trading pipeline.

In Part IV, we extended the Interactive Supply and Demand Zone Manager beyond zone detection and lifecycle tracking by connecting validated supply and demand zones to a trading layer. The framework could now evaluate zone interactions and use them as part of an automated trading workflow.

After a restart of the Expert Advisor or the trading terminal, the zone engine in its previous form could rediscover rectangles on the chart but lost all runtime continuity: lifecycle status (Virgin/Broken/Inactive), interaction history and touch counts, scores and tiering, buy/sell trigger flags, blacklist entries, and the managed geometry of user-drawn zones. In practice this causes restored zones to behave as new ones — risks include duplicate or inappropriate trade entries, incorrect filtering, desynchronized visuals and logic, and the need for users to redraw or reconfigure manual boxes.

Part V remedies this by adding a persistence layer that records the logical state of the zone engine per trading context (symbol + timeframe). The persistence design intentionally separates runtime behavior from durable state: SZonePersist is a plain-data snapshot that captures identity, geometry, timing, scores/telemetry, lifecycle flags and user time anchors; CZone remains responsible for detection, lifecycle evaluation and trading. On OnInit(), the framework restores the saved zone properties and lifecycle flags, reconciles their chart objects, and applies the existing startup relevance checks. Persistence remains separate from detection and execution.


Author: Francis Nyoike Thumbi