Loading…

Structured Variable Dumper

MQL4 has no reflection, so no header can be handed an arbitrary struct and print its fields automatically - the caller always names each field explicitly. What ad-hoc Print calls lack is consistency: formatting drifts between debug sessions, arrays get dumped with a raw loop that either floods the Journal for a large array or gets skipped entirely because writing that loop every time is tedious, and there is no nesting for a field that is itself a small group (one element of a struct array, say). This header gives a small stateful dump builder: SvdBegin starts a titled dump, SvdAddIntField/SvdAddDoubleField/SvdAddBoolField/SvdAddStringField add scalar "name = value" lines, and SvdAddIntArrayField/SvdAddDoubleArrayField/ SvdAddStringArrayField add an array's contents with its length and a caller-chosen truncation cap - past that cap the line ends with "... (+N more)" rather than silently stopping. SvdIndentIn/SvdIndentOut nest a group of fields under a label. SvdGetDump reads back the accumulated text; SvdPrintDump prints it one Journal line per accumulated line. Notes and limitations No reflection: there is no way to hand this header a struct instance and get its fields dumped automatically, every field is added by an explicit call - this is a formatting/truncation convenience, not an automatic serialiser. The dump buffer is a single global string built up since the last SvdBegin, so only one dump can be under construction at a time; a second SvdBegin call before SvdGetDump/SvdPrintDump on the first discards it. Array truncation counts items, not characters, so a truncated array of very long strings can still produce a long single line. SvdPrintDump splits on embedded newlines and prints each non-empty line separately for Journal readability; SvdGetDump returns the untouched buffer with newlines intact for callers writing to a file instead.

Script · MT4 · v1.0 · Free

About Structured Variable Dumper

Structured Variable Dumper is a script for MetaTrader 4. It shows several symbols in one panel and is set up for gold (XAUUSD). It has 1 setting, such as Max array items. MQL source code included.

Files in the download: StructuredVariableDumper.mqh, StructuredVariableDumper.txt, StructuredVariableDumperDemo.mq4.

Settings

SettingDefaultWhat it does
Max array items5truncate array dumps past this many items (0 = never truncate)

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 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: Trading Sessions · Dashboards & Scanners · Gold (XAUUSD) · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria