This repository is an article-derived reference project based on the original MQL5 article. It does not claim to reproduce the full original source code unless files are explicitly attached.
## Overview
This project documents the MQL5 article implementation that replaces a compile-time CSV news source with a shared SQLite database layer for a news dashboard Expert Advisor.
The described design persists:
- economic calendar event history
- triggered trade event IDs for restart-safe deduplication
- a shared data store accessible from both live charts and the Strategy Tester
The article also adds a canvas-based download progress bar and a live-mode historical download workflow.
This repository serves as a reference/reconstruction project for the article<6C>s architecture and code excerpts around persistent calendar storage in MQL5.
Its purpose is to capture the database-centered redesign introduced in this article:
- replacing embedded CSV resources with SQLite
- storing the database in the common terminal folder
- sharing one persistent store between live mode and tester mode
- restoring triggered trade IDs after restart
- downloading historical calendar data on demand without recompilation
## Key Concepts
- SQLite integration through the MQL5 Database API
- common-folder database sharing via `DATABASE_OPEN_COMMON`
- schema creation for `events` and `triggered` tables
- upsert-based event persistence using `INSERT OR REPLACE`
- transaction-based bulk writes for calendar history imports
- time-window event loading for tester execution
- trade deduplication persistence using stored triggered event IDs
- pruning old rows to limit database growth
- canvas-based progress bar visualization during downloads
- unified refresh logic across live and tester workflows
## Algorithm / Architecture Summary
The article describes a two-table SQLite design:
1.**`events` table**
- stores calendar value records and display/trading metadata
- uses `value_id` as the primary key
- indexes `event_time` for fast time-range queries
2.**`triggered` table**
- stores previously traded `event_id` values
- preserves deduplication state across restarts
### Runtime flow
- **Initialization**
- open or create the shared database
- create required schema if missing
- branch by runtime mode:
- **tester mode:** load events for the configured backtest window from SQLite
- **live mode:** prune old rows, restore recent triggered IDs, optionally download historical data, then load current live events
- **Live download path**
- query calendar history from the MQL5 calendar API
- enrich values with event/country metadata
- convert them into the EA<45>s `NewsEvent` structure
- upsert rows in a single database transaction
- display progress using a `CCanvas` overlay
- **Trade deduplication**
- append fired event IDs to an in-memory array
- persist them into the `triggered` table
- reload the last 24 hours of triggered IDs on restart
- **Tick handling**
- use a single refresh path
- redraw only when the event set changes
- keep trade checks active on every tick
## Mentioned or Attached Files
### Explicitly attached files
-`MQL5 News Calendar EA PART 12.mq5`<20> main Expert Advisor entry point
-`News Core.mqh`<20> shared data definitions, theme/layout data, helper structures
- The full original repository content is not independently verified here beyond the article text and listed attachments.
- This README is based on the article narrative and code excerpts; some implementation details may depend on prior parts of the series.
- If the actual attached source files are not present in the processed repository input, this project should be treated as a reference reconstruction rather than a complete build-ready codebase.
- Installation, compilation, and execution steps are not provided here because the article excerpt does not fully specify the complete environment and dependency setup.
## Reference
Original article: [https://www.mql5.com/en/articles/22608](https://www.mql5.com/en/articles/22608)