Loading…

Report Section Composer

A plain-text report (a header banner, a block of aligned key/value lines, a padded table, a percent bar) is rebuilt from scratch by hand in almost every reporting script - manual string padding, manual rule lines, and usually no real CSV escaping at all (a symbol comment containing a comma silently shifts every column after it in a naive CSV export). ReportSectionComposer centralises that formatting into a small append-only line buffer (RscBuilder). Compose a report by calling RscAddSectionHeader(), RscAddKeyValue(), RscAddTableRow(), RscAddCsvRow(), RscPercentBar() and friends in sequence, then either flatten the whole thing to one string with RscToText() for Print()/ Comment()/Alert(), or stream it line-by-line into an already-open file handle with RscWriteToFile(). RscAddCsvRow() implements the standard RFC 4180 escaping rule: any cell containing a comma, a double quote, or a newline gets wrapped in quotes with internal quotes doubled. This is the trap most hand-rolled CSV exports in this kind of tool get wrong - a trade comment like "SL hit, spread widened" silently corrupts every column after it without proper escaping, and the corruption is easy to miss because the file still opens fine in a spreadsheet, just with the wrong data in the wrong columns. Notes and limitations - The line buffer is a FIXED-size array of RSC_MAX_LINES (512) inside the RscBuilder struct, not a dynamic array - this is deliberate so the struct copies/assigns/returns safely by value like any ordinary MQL4 variable. Composing past 512 lines silently stops accepting new lines and sets the truncated flag rather than crashing; check RscIsTruncated() after building a very large report. Raise RSC_MAX_LINES and recompile if a project genuinely needs more. - RscAddTableRow() left-pads with spaces to the given column width but does not truncate an over-long cell, so an unusually long value can still push later columns out of alignment in a monospaced viewer. Size column widths generously for the data actually expected. - CSV escaping follows RFC 4180 (quote-wrap on comma/quote/newline, double internal quotes) but the delimiter itself is a plain parameter, not auto-detected - if a caller passes a semicolon delimiter, only commas/quotes/newlines still trigger quoting, not semicolons. - This header does no file I/O of its own beyond RscWriteToFile() writing lines into a handle the caller already opened; opening, closing, and choosing the file mode remain the caller's responsibility.

Script · MT5 · v1.0 · Free

About Report Section Composer

Report Section Composer is a script for MetaTrader 5. It shows several symbols in one panel and is set up for gold (XAUUSD). It has 1 setting, such as Output file name. MQL source code included.

Files in the download: ReportSectionComposer.mq5.mqh, ReportSectionComposer.txt, ReportSectionComposerDemo.ex5, ReportSectionComposerDemo.mq5.

Settings

SettingDefaultWhat it does
Output file nameReportSectionComposerDemo.txtOutput file, written under MQL5\Files\

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: Dashboards & Scanners · Gold (XAUUSD) · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria