Loading…

Export Schema Validation Gate

Every export script in this catalogue writes a header row and a fixed column shape, but nothing checks afterward that the shape is still intact. A file that has been through email, a spreadsheet re-save, or manual editing can end up with a reordered column, a truncated row, or a value that quietly turned into text where a number was expected - and none of that throws an error on its own. It just makes every downstream number land in the wrong place, silently. This script reads a small, documented "schema description" text file - one line per expected column, in order, giving its name and type - and checks a CSV data file against it column by column, row by row. Anything wrong is reported with the exact row number and column name: a header that doesn't match, a row with the wrong field count, a value that isn't a valid int/double/date for its column. A full CSV report of every problem is also written alongside the journal output, so a long list of failures can be opened and worked through in a spreadsheet rather than scrolled through in the Experts tab. The schema description format is deliberately tiny - one line per column, "name:type" or "name:type:optional" - so a schema file for any export in this catalogue (or any external CSV) can be written by hand in under a minute rather than needing a separate schema-authoring tool. Notes and limitations This checks shape and value format, not business meaning - a schema saying a column is "double" accepts -999999.99 just as happily as a sane price. It catches structural corruption (reordered/missing columns, wrong field count, text where a number belongs), not domain-level nonsense. Field parsing has no quoting support of its own for the schema file, but the data file is read through FILE_CSV mode, which already handles quoted fields containing the delimiter the same way any other CSV export in this catalogue writes them. A completely empty data file (header only, or nothing at all) reports 0 rows checked and 0 problems - that is a pass on structure, but an empty export is very likely still worth a second look on its own.

Script · MT5 · v1.0 · Free

About Export Schema Validation Gate

Export Schema Validation Gate is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 3 settings, such as Schema file, Data file and Max errors to print. MQL source code included.

Files in the download: ExportSchemaValidator.ex5, ExportSchemaValidator.mq5, ExportSchemaValidator.txt.

Settings

SettingDefaultWhat it does
Schema fileSchema description file, in MQL5\Files (see .txt for the mini-format)
Data fileCSV data file to validate, in MQL5\Files
Max errors to print50Stop printing after this many error lines (the CSV report still lists all)

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria