Skip to content
All library documents

Fail-Closed Decision Files for Automated Trading Systems

Article MQL5 code base

Summary

The document describes a watchdog for automated systems that read a daily file specifying which strategy to run or whether to remain flat. Its motivating failure occurred when a missed daily update left a prior decision in place, while a server clock moving backward made that stale file appear current. The proposed safeguard checks the file date against local time, which the document says moves forward, instead of relying on the last-tick server time.

The reader treats missing files, invalid dates, dates from the wrong day, and absent decision text as reasons to return a flat instruction. It also logs each failure once per state change to avoid both repeated log noise and silent failure. A two-line file format and a demonstration covering valid, stale, malformed, empty, and missing inputs are described; the demonstration does not place trades. The approach addresses stale-input handling and operational reliability, but the document does not discuss clock synchronization, time zones, file-write atomicity, or recovery after a valid update. Those issues would need separate safeguards in deployment.

Key ideas

  • A daily decision file can become stale if its writer fails to run.
  • The watchdog judges freshness using local time because the server's last-tick time may freeze or move backward.
  • Missing, malformed, outdated, or incomplete inputs lead to a flat decision.
  • Logging once per state change limits repeated messages while preserving notice of failures.
  • The demonstration checks file-handling cases but does not execute trades.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.