Discussing the article: "Real-Time Trade Event Logger to SQLite via MQL5 DLL Bridge"

 

Check out the new article: Real-Time Trade Event Logger to SQLite via MQL5 DLL Bridge.

The article shows how to build an MQL5 EA that writes every deal to an SQLite database the moment it appears, using the built-in Database API as the SQLite bridge. It implements an event data model, a prepared INSERT workflow reused across calls, session-safe recovery after restarts, and deal detection via OnTrade(). You can open the resulting file with any SQLite client to run queries for analysis and reporting.

Every trade executed on a MetaTrader 5 account produces a deal record: a timestamped entry capturing the instrument, direction, price, volume, profit, and a dozen other properties. The terminal stores these records internally and displays them in the History tab, but the storage is opaque. There is no way to run an SQL query against it, filter it by time of day, join it with external data, or feed it into a reporting pipeline. The built-in export options produce static HTML files. They require manual conversion before a spreadsheet or analysis tool can use them meaningfully. They also capture a snapshot rather than a live stream.

This article builds an Expert Advisor that solves the problem by writing every trade event to an SQLite database file the moment it occurs. On each OnTrade() callback, the EA detects deals that arrived since the previous call. It builds a structured record for each deal and inserts it into the trade_events table using parameterized SQL. The database file lives in MQL5/Files/ and can be opened simultaneously by SQLite-compatible tools (DB Browser for SQLite, Python's sqlite3 module, R's RSQLite package) and BI platforms that support SQLite. The bridge between MQL5 and the SQLite engine is the terminal's own built-in Database* API, which exposes a full parameterized SQL interface to the SQLite library bundled with MetaTrader 5 from build 2485 onward.

Author: Ushana Kevin Iorkumbul