Loading…

Set File Matrix Generator

MT4's own Strategy Tester optimiser sweeps one min/step/max range per input at a time. It has no way to hand a trader a folder of ready-made .set files for a specific, hand-picked combination grid - three particular stop distances crossed with four particular session-start hours, say - to load individually, attach to different demo charts, or compare side by side outside the optimiser's own results grid. This script reads a base .set file (every key it does not touch keeps its base value unchanged) and a small matrix spec file listing which keys to vary and the exact candidate values for each. It then writes one .set file per combination in the cartesian product of those value lists, plus a manifest CSV mapping every generated filename to the exact combination of values it holds - the numbered filename alone would not tell you which combination is which. The combination count grows fast: three keys with five values each is already 125 files. Rather than silently writing however many files the grid works out to, the script computes the total up front and refuses to run at all past a configurable cap, so a mistyped or over-ambitious matrix spec fails immediately with a clear count instead of flooding the Files folder. Notes and limitations This generates input files only - it does not run the Strategy Tester or attach the resulting .set files to anything itself. Loading each generated file (Strategy Tester "Load" button, or an EA's own input-load dialog) is a manual step outside what a Script is allowed to automate. Values in the matrix spec are copied through as plain text with no type checking against what the target EA/indicator actually expects for that key - a value list with a typo (a stray space, a wrong decimal separator) produces a .set file that loads but silently misconfigures that input. Check one or two generated files by eye before running a full batch through the tester. Every key present in the base file but not varied is copied through unchanged, including its optimiser start/step/stop/enabled flags where the base file has them.

Script · MT5 · v1.0 · Free

About Set File Matrix Generator

Set File Matrix Generator is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Base set file, Matrix file and Output prefix. MQL source code included.

Files in the download: SetFileMatrixGenerator.ex5, SetFileMatrixGenerator.mq5, SetFileMatrixGenerator.txt.

Settings

SettingDefaultWhat it does
Base set fileBase .set file, in MQL5\Files - every non-varied key keeps this value
Matrix fileMatrix spec file, in MQL5\Files (see .txt for the mini-format)
Output prefixMatrix_Filename prefix for every generated .set file
Max combinations500Hard cap - the run aborts instead of writing more than this many files

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: Grid · Trading Sessions · Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria