History Export Completeness Verifier
The Account History tab at the bottom of the MetaTrader 4 terminal has a right-click period selector - Last Week, Last Month, Last 3 Months, All History, and so on - and it is easy to forget it is set to anything other than "all". What is not obvious is that this same setting limits what OrdersHistoryTotal() and OrderSelect(..., MODE_HISTORY) return to MQL4 code, not just what the tab displays on screen. Any script or export tool that reads trade history through the normal API silently sees only what that dropdown currently allows, with no error and no warning that anything was left out. There is no MQL4 API to ask the server directly how much history actually exists, so this script cannot prove truncation with certainty - it checks for two symptoms it CAN detect honestly and reports them as warning signs, not proof. First, if you tell it the earliest trade date you actually expect, it flags the earliest record found being later than that. Second, independent of any input, it checks whether the earliest record found sits suspiciously close to one of the History tab's own standard preset boundaries measured back from now - a coincidence that is exactly what truncation looks like, even though on its own it cannot be told apart from genuinely starting to trade on that same day. Notes and limitations - This is a heuristic check, not a definitive one. A clean result means no warning sign was found, not that the history is certainly complete - a History tab set to a very generous period, or an account that genuinely started trading near a preset boundary, will not be flagged. - OrdersHistoryTotal() returning zero is reported as its own separate, unambiguous warning, since a real trading account with zero history records almost always means the tab is filtering everything out rather than the account never having traded. - The boundary-proximity check compares against five common presets (week/month/3 months/6 months/year); a broker or terminal build using a different custom preset will not be matched by name, though a genuinely truncated result may still trip the "expected earliest trade" check if that input is set. - This script only reads history; it never opens, closes or modifies a trade, and it cannot change the History tab's setting for you - only point you at the fix.
Script · MT5 · v1.0 · Free
About History Export Completeness Verifier
History Export Completeness Verifier is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 2 settings, such as Expected earliest trade and Boundary tolerance days. MQL source code included.
Files in the download: HistoryCompletenessVerifier.ex5, HistoryCompletenessVerifier.mq5, HistoryCompletenessVerifier.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Expected earliest trade | 0 | Earliest trade date you actually expect (1970.01.01 = skip this check) |
| Boundary tolerance days | 2 | Days of slack when matching a common history-window preset |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Alerts · MT5 Script · MQL5 Source Code