Skip to content
All library documents

Persisting Economic Calendar Data and Trade Deduplication with SQLite

Article MQL5 articles

Summary

This article presents an MQL5 design for storing economic-calendar events and previously triggered trade IDs in a shared SQLite database. It replaces embedded CSV test data and memory-only trade records with an events table and a deduplication table in the common terminal folder. In live mode, calendar updates are written to the database; in the strategy tester, events are loaded from that same store for the selected test period. The design also supports downloading historical date ranges on demand and displaying progress during the download.

The article describes the schema, indexed time queries, event upserts, transactions, startup restoration of recent triggered IDs, and integration with a dashboard and trade logic. Its evidence consists of implementation detail and a described working interface, not measured trading or backtest results. Sharing one database between live and tester environments simplifies data reuse, but the article does not discuss contention, operational recovery, or the effect of calendar-based trades on strategy performance.

Key ideas

  • A shared SQLite database can provide calendar data to both live operation and strategy testing.
  • Event rows can be upserted so later calendar values update existing records instead of creating duplicates.
  • A primary key on triggered event IDs can preserve trade deduplication across program restarts.
  • An indexed event-time column supports loading calendar records for a selected time window.
  • The article explains database and dashboard implementation but provides no strategy performance evaluation.

Tags

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