Loading…

Terminal Log Line Parser

MetaQuotes does not publish the terminal's log column layout as a stable, documented API - this library targets the tab-separated "HH:MM:SS.mmm<TAB>Source<TAB>Message" shape as written into MQL4\Logs\YYYYMMDD.log and the terminal's own logs\YYYYMMDD.log files, which has been stable across recent builds. A line that does not match this exact shape is rejected (ParseLine returns false) rather than guessed at - a tool built on a partially-matched, silently-wrong record is worse than one that visibly skips a line it does not recognise. Two things are extracted per line beyond the raw text. First, the Source column is classified: "EURUSD,H1" style text is recognised as a chart context and split into symbol/period, while anything else ("Trades", "Experts", "Alert") is kept as a plain terminal channel name. Second, the Message column is checked against a well-known trade event shape - "'12345678': buy 0.10 EURUSD at 1.10500 ..." - and, when it matches, decomposed into ticket, verb, volume, symbol and price fields so a caller does not have to re-parse that text itself. This turns a raw log file into something a monitoring script, a post-mortem tool, or a "did my EA actually place this order" checker can walk field by field instead of doing its own ad hoc string scanning on every use. Notes and limitations - Targets one specific, reverse-engineered log line shape. If a given terminal build or export format differs (a different column separator, an extra leading index column), treat this as a template to adjust the ParseLine()/ParseSource() logic against, not a universal log parser. - The trade-event sub-pattern recognises one common message shape ("'ticket': verb volume symbol at price ..."). Other message text - including many other legitimate trade-related messages - simply leaves isTradeEvent false; it is not an error, just "not that particular shape". - No file-reading code is included - this library only parses lines you already have as strings; read them from disk with ordinary FileOpen/FileReadString calls first.

Script · MT5 · v1.0 · Free

About Terminal Log Line Parser

Terminal Log Line Parser is a script for MetaTrader 5. MQL source code included.

Files in the download: TerminalLogLineParser.mq5.mqh, TerminalLogLineParser.txt, TerminalLogLineParserDemo.ex5, TerminalLogLineParserDemo.mq5.

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: Risk & Lot Size · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria