Discussing the article: "Trading with the MQL5 Economic Calendar (Part 12): SQLite Storage and Deduplication"
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: Trading with the MQL5 Economic Calendar (Part 12): SQLite Storage and Deduplication.
In this article, we replace the embedded CSV snapshot with a SQLite layer that persists calendar events and triggered trade IDs across restarts. The database lives in the common terminal folder and is shared by live charts and the strategy tester, so both modes read the same data without recompiling. An on-demand downloader with a canvas progress bar fetches history from the calendar API and stores it for offline reuse.
The new design replaces both halves of that split with a single SQLite database file living in the common terminal folder. SQLite is a self-contained database engine built into the MetaTrader 5 runtime through the Database API, which gives us familiar tools — create tables, prepare statements, bind parameters, run transactions, and query rows — all from inside MQL5. The common folder placement means the live chart agent and every strategy tester agent point at the same physical file. Whatever live mode learns about the calendar, the tester can read. Whatever the tester is given to chew on, the live chart sees it too. Two tables sit inside that file: one holds the events themselves with every field needed for unit-aware display and trade decisions, and the other holds the IDs of news events that have already fired trades so the deduplication set survives restarts.
The data flow becomes asymmetric and clean. In live mode, every refresh of the calendar API now upserts each event into the database within a single transaction, so the disk picture stays in sync with what the program sees in memory. A new input lets the user request a one-time download of any historical date range to seed the database, with a progress bar overlay showing percentage and record counts as the rows accumulate. In tester mode, the program does no API calls at all — it queries the events table for the configured backtest window and feeds the result straight into the same filtering and rendering pipeline used by live mode. The triggered trade list is loaded once at startup from the last twenty-four hours of database history, restoring whatever deduplication context the previous session left behind. Below is a visualization of what we intend to achieve.
Author: Allan Munene Mutiiria