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 · MT5 · v1.0 · Free
About Optimisation Set Generator
Optimisation Set 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, Rules file name and Output set file. MQL source code included.
Files in the download: OptimisationSetGenerator.ex5, OptimisationSetGenerator.mq5, OptimisationSetGenerator.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Base set file | Existing .set file to use as a template, from MQL5\Files | |
| Rules file name | optimisation_rules.csv | Rules CSV: parameter,start,step,stop,optimize |
| Output set file | generated.set | Output file, written to MQL5\Files |
| Force others off | true | Turn optimisation off for every parameter not in the rules file |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Alerts · MT5 Script · MQL5 Source Code