Loading…

Optimisation Set Generator

Setting up a large optimisation in the Tester dialog means opening Expert Properties, clicking into each parameter's range fields one at a time, and doing it again for every variant of the sweep you want to run. For a dozen parameters across several sweep configurations, that is a lot of clicking for something that is really just a table of numbers. This script writes that table instead. It reads a CSV of parameter, start, step, stop, optimise-flag rows and applies them to a .set file, producing a new .set with exactly those ranges set and every other parameter's optimise flag turned off by default, so a large sweep only touches the parameters named in the rules file. The detail that matters here is where the base .set file comes from. The exact byte format MetaTrader uses for a .set entry is not published by MetaQuotes, and a script that fabricates that format from a written description risks producing a file the terminal quietly refuses to load correctly - the kind of failure that is not discovered until the optimisation dialog shows something unexpected. This script sidesteps that risk entirely: point it at a .set file you have already saved once from the Tester's own Expert Properties > Save button, a file the terminal is guaranteed to read because it wrote it, and only the numeric range fields are rewritten. Every other line, and every field this script was not told to change, passes through byte-for-byte. Notes and limitations - Requires a genuine .set file saved by MetaTrader itself as the starting point. There is no "build one from a list of parameter names" mode, deliberately, because the byte format is not something this script can verify independently of the terminal that wrote it. - A rule naming a parameter that does not exist in the base file is reported by name in the log and simply has no effect - it is not treated as an error that stops the run, since one typo should not block the parameters that were spelled correctly. - The "current value" field of each rewritten parameter - what a non-optimising single test run would use - is left exactly as it was in the base file. This script only ever changes the range, never the default. - Non-numeric or string parameters, and any line without the five-field optimisable shape, are copied through unchanged.

Script · MT4 · v1.0 · Free

About Optimisation Set Generator

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

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

Settings

SettingDefaultWhat it does
Base set fileExisting .set file to use as a template, from MQL4\Files
Rules file nameoptimisation_rules.csvRules CSV: parameter,start,step,stop,optimize
Output set filegenerated.setOutput file, written to MQL4\Files
Force others offtrueTurn optimisation off for every parameter not in the rules file

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