Loading…

Aligned Text Table Formatter

A table built with plain string concatenation drifts out of alignment the moment one row's cell text is a different length from the row above it - a bid price of 1.2 next to one of 123.45, or a short symbol name next to a long one. In a monospace context (the Experts/Journal log, an OBJ_LABEL panel set to a monospace font, or a plain-text export file) that drift is the difference between a table that reads at a glance and a wall of text nobody can scan. This header pads every cell to a known column width before joining it into a row, with left, right and centre alignment available per column. Since column widths usually depend on content that isn't all available up front (you don't know the widest symbol name until you've seen every row), it follows the standard two-pass pattern: grow a widths array across every row first with AttfGrowWidths, then format every row a second time now that the true widths are known. A dashed separator-line builder is included for a header/body divider. Notes and limitations Column widths are measured in characters (StringLen), not rendered pixel width - this header assumes a monospace font or a plain-text destination where character count and visual width are the same thing; it will not line up correctly in a proportional-width font. Padding never truncates an over-long cell - a cell wider than its column's computed width is left as-is rather than cut off, so a very long outlier value can still push a row wider than the rest of the table; grow the width array from that same data first (as the demo does) if consistent width is required. AttfFormatRow/AttfFormatRowAligned stop at the shortest of their input arrays if cols/widths/aligns are mismatched in length, rather than raising an error - callers should keep those arrays the same size as their column count.

Script · MT5 · v1.0 · Free

About Aligned Text Table Formatter

Aligned Text Table Formatter is a script for MetaTrader 5. It shows several symbols in one panel and is set up for gold (XAUUSD). MQL source code included.

Files in the download: AlignedTextTableFormatter.mq5.mqh, AlignedTextTableFormatter.txt, AlignedTextTableFormatterDemo.ex5, AlignedTextTableFormatterDemo.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: Dashboards & Scanners · Gold (XAUUSD) · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria