Markdown Report Builder
An EA or script that writes an end-of-run report, a diagnostic dump, or a Discord/Slack-bound summary (Markdown renders on both) ends up hand- building the same handful of Markdown constructs over and over: a heading needs the right number of "#" characters, a table needs a header row plus a separator row of "---" cells, a numbered list needs the index typed by hand at every item. Small as each piece is, doing it inline at every call site invites inconsistency - a table built in one function with two dashes per separator cell and another built elsewhere with three. CMarkdownBuilder centralises this: AddHeading, AddParagraph, AddBulletList, AddNumberedList, AddTable, AddCodeBlock and AddHorizontalRule each append correctly-formatted Markdown to an internal buffer, and GetText() returns the finished document at the end. Table cells are escaped automatically. GitHub-flavoured Markdown tables are one physical output line per row - a literal, un-escaped "|" character inside a cell's text silently corrupts every column to its right for the rest of that row, and a raw newline inside a cell breaks the table entirely, splitting it into two malformed rows. AddTable() escapes every "|" to "\|" and collapses any embedded newline to a single space in every cell it writes, so a P&L description or a free-text note field can be dropped straight into a table cell without the caller having to sanitise it first. MQL4 cannot ArrayResize a dimension other than an array's first, so there is no true 2-D dynamic array to hand AddTable() a natural row/column grid. Table data is passed as one flat string array plus an explicit column count, indexed row*columnCount+col - the same flattening technique used throughout this catalogue wherever tabular data needs a resizable row count with a fixed column shape. Notes and limitations - AddTable() escapes cell content for table safety only - it does not escape Markdown emphasis characters (*, _, `) inside cells, so a cell containing "*bold*" will render as bold text in most Markdown viewers. Escape those yourself first if literal asterisks/underscores in cell text matter for a given report. - AddRaw() bypasses every safety mechanism in this library - text passed to it is appended completely unmodified, including any '|' or newline characters. Use it only for pre-formatted Markdown you already trust. - This is a plain fenced-block/GFM-table subset of Markdown, not the full CommonMark specification - no support for footnotes, nested blockquotes, or reference-style links. - Heading level is silently clamped to 1..6 rather than rejected; passing 0 or 9 produces a level-1 or level-6 heading respectively.
Script · MT4 · v1.0 · Free
About Markdown Report Builder
Markdown Report Builder is a script for MetaTrader 4. MQL source code included.
Files in the download: MarkdownReportBuilder.mqh, MarkdownReportBuilder.txt, MarkdownReportBuilderDemo.mq4.
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: MT4 Script · MQL4 Source Code