Skip to content
All library documents

Using StringFormat to Build Reusable Symbol-Property Reports

Article MQL5 articles

Summary

This reference article explains how MQL5’s StringFormat function returns formatted text for reuse, unlike PrintFormat, which writes formatted output directly to the terminal journal. It outlines format specifiers, including examples showing how integer width affects decimal and hexadecimal output. The main application is a set of reusable functions that retrieve, format, and optionally print symbol properties with aligned labels and indentation.

The examples cover integer, real, and string properties, including trading-session data, execution settings, prices, contract details, swaps, margins, and option fields. The article also shows a function for representing timestamps with millisecond precision and describes checking whether a symbol exists or is selected before requesting some properties. Its evidence consists of code examples and sample journal output rather than trading-performance analysis. This is primarily an MQL5 programming reference for building structured logs or diagnostic reports; it does not present a trading strategy or test whether the displayed properties improve trading decisions.

Key ideas

  • StringFormat returns a formatted string that a program can store and reuse.
  • Format specifiers must match the types and widths of the supplied values.
  • Reusable helper functions can present symbol properties with consistent labels and alignment.
  • Some symbol properties require the symbol to be selected in Market Watch before retrieval.
  • The examples support diagnostics and logging rather than testing a trading strategy.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.