Loading…

Optimisation Result Ranker

The Optimization Results tab sorts every pass by one column - usually net profit, sometimes a custom criterion. The pass at the top of that list is very often the one that happened to line up best with the sample, not the one that would hold up on data it has not seen. A handful of oversized wins on a thin trade count can outrank a steadier pass with a much better profit factor, purely because the sort column cannot see the difference. This script reads a CSV already exported from the Optimization Results tab (right-click the results grid, Save as CSV or Save as Report) and computes its own robustness score for every pass: profit factor above 1, weighted, minus a weighted penalty for drawdown percentage. Passes whose trade count falls under a configurable threshold are flagged separately and carry an extra penalty, because a strategy that only fired thirty times in the whole sample has not really been tested yet regardless of how clean its equity curve looks. Every original column survives untouched in the output - including whatever parameter values were swept - with two new columns appended: the computed score and the low-sample flag. The file is re-sorted best score first, so the candidates worth a closer look, and a walk-forward or out-of-sample check, are together at the top. Notes and limitations - The score is a transparent formula, not a claim of statistical significance. It is built from exactly the two weights and the two inputs described above - read them back from the formula rather than treating the number as an authority. - Requires a header row containing columns whose names include "Profit Factor" and "Drawdown" together with "%" (case-insensitive substring match). A results export with different column names will be rejected with a clear message rather than silently misreading the wrong columns. - The input file's delimiter is detected by counting commas, semicolons and tabs in the header line and picking the most frequent. A single-column export with no real delimiter cannot be ranked. - Column splitting is a plain delimiter split, not a quote-aware CSV parser. A field that itself contains the delimiter (rare in a tester export, since parameter values and metrics are numeric) would be misread. - A low trade count is flagged, not excluded. Every pass from the input still appears in the output; the flag and the score are there to help you decide, not to hide data.

Script · MT4 · v1.0 · Free

About Optimisation Result Ranker

Optimisation Result Ranker is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 7 settings, such as Input filename, Output delimiter and Weight profit factor. MQL source code included.

Files in the download: OptimisationResultRanker.ex4, OptimisationResultRanker.mq4, OptimisationResultRanker.txt.

Settings

SettingDefaultWhat it does
Input filenameOptimisation results CSV, in MQL4\Files
Output delimiterDelimiterCommaDelimiter for the ranked output file
Weight profit factor1.0Weight applied to (Profit Factor - 1)
Weight drawdown percent1.0Weight applied to the drawdown-% penalty
Min trades30Trades below this count are flagged low-sample
Low sample penalty1.0Score penalty applied to low-sample passes
Max rows20000Safety cap on optimisation passes processed

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: Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria