Loading…

League Table Builder

Comparing several strategies or symbols side by side means collecting a name and a metric value per row, then presenting them in ranked order - but a single sort direction silently mis-ranks half of what traders actually compare. Net profit and win rate are "bigger is better"; drawdown and average loss are "smaller is better". A league table that only ever sorts one way either shows drawdown backwards or forces the caller to negate values by hand. This header collects entries with LtbAddEntry, then offers LtbSortDescending (rank 1 = highest metric) and LtbSortAscending (rank 1 = lowest metric) as separate calls, so the caller picks the direction that matches the metric's meaning rather than negating anything. LtbBuildTable then renders the current order as an aligned rank/name/metric text table sized to the widest name and metric actually present, ready to print to the Journal or drop into a document. Ties are given sequential ranks in the order they were encountered by the sort, not a shared rank number - a genuine simplification worth knowing about rather than a bug, documented below. Notes and limitations Fixed capacity of 64 entries (LTB_MAX_ENTRIES) - LtbAddEntry returns false without adding once the table is full, it never overflows or reallocates. Sorting is a plain insertion sort, adequate at this capacity but not written for large datasets. Ties keep whatever relative order the insertion sort leaves them in (stable in practice for this implementation, but not documented as a guaranteed stable sort contract) and are numbered sequentially rather than sharing a rank - a table with two equal top scores shows rank 1 and rank 2, not two rank-1 rows. Column widths are measured in characters, so the printed table lines up correctly only in a monospace context (the Journal log, a monospace-font panel, or a plain-text export), same as any other fixed-width text table in this catalogue.

Script · MT5 · v1.0 · Free

About League Table Builder

League Table Builder is a script for MetaTrader 5. It has 1 setting, such as Decimals. MQL source code included.

Files in the download: LeagueTableBuilder.mq5.mqh, LeagueTableBuilder.txt, LeagueTableBuilderDemo.ex5, LeagueTableBuilderDemo.mq5.

Settings

SettingDefaultWhat it does
Decimals2decimal places shown for the metric column

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: MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria