How to export your MT5 optimization results to XML
To analyze an optimization outside MetaTrader 5, in Excel or in Orometra, you need its results as a file. MT5 does it in a few clicks, but a couple of details decide whether the file is any use. This guide walks you through the whole process: setting up the tester, exporting both tables, checking the files and the mistakes that ruin the analysis.
Before optimizing: set up the tester
Open the Strategy Tester with Ctrl+R (or View → Strategy Tester). In the Settings tab you choose the EA, the symbol, the timeframe and the dates. Three settings there decide what you will be able to conclude later:
- Forward. Choose 1/2, 1/3 or 1/4, or Custom to set its start date yourself. MT5 keeps that final part of your dates aside: it optimizes on the first part (the in-sample) and then runs the passes again on the rest (the forward). Without a forward you only have in-sample results, and no analysis can tell a robust configuration from a lucky one with confidence. The forward testing guide explains it in detail.
- Modeling. It decides how faithfully prices are simulated. The fast modes are fine for exploring; the configuration you end up choosing deserves “Every tick based on real ticks”. The report guide explains each mode.
- Optimization. “Slow complete algorithm” tests every combination; “Fast genetic based algorithm” tests a part of them. Next to it you choose the criterion. The guides on genetic or complete optimization and on the optimization criterion help you choose.
In the Inputs tab, tick the parameters you want to optimize and give each one a Start, a Step and a Stop. The ones you leave unticked keep their Value during the whole optimization. Before you launch it, multiply the number of values of each parameter: that is how many backtests MT5 will run in a complete search.
Export the optimization results
When the optimization finishes, open the Optimization Results tab and make sure you are looking at the table, not at the optimization graph. Right-click anywhere in the table and choose the option to export to XML (in English, “Export to XML”; the exact wording varies with the MT5 version and language). MT5 asks where to save it: use a name you will recognize later, for example EURUSD-H1-2020-2024-in-sample.xml.
Despite the extension, the file is a spreadsheet in Microsoft’s XML Spreadsheet format: Excel and LibreOffice open it as a table. It has one row per pass and one column per metric and per parameter. In an English terminal the metric columns are usually Pass, Result (the value of the criterion you optimized), Profit, Expected Payoff, Profit Factor, Recovery Factor, Sharpe Ratio, Custom, Equity DD % and Trades, followed by your parameters, one column each.
What it does not contain is the equity curve or the list of trades of each pass: only these totals. That is a limit of the MT5 export, and it is why some analyses that need the curve of every configuration cannot be done from this file.
Export the forward results
If you turned on Forward, there is another tab with a second table: the forward results. Export it the same way, for example as EURUSD-H1-2020-2024-forward.xml. It may have fewer rows than the first one: according to the MT5 help, the forward only re-tests the best passes of the optimization, ranked by your criterion (the top 10% with the complete algorithm and the top 25% with the genetic one, with a minimum number of passes). Some real exports bring every pass instead. Orometra works with both.
Its columns are almost the same, with two that matter: Forward Result, the criterion measured on the forward period, and Back Result, the criterion of that same pass in the optimization period. The other metrics (profit, drawdown, trades…) are those of the forward. That is how Orometra tells the two files apart, whichever order you drop them in, and how it checks that they come from the same optimization: the Back Result of each pass must match its Result in the other file.
Optional: the .set with your ranges
In the Inputs tab, right-click the list of parameters and choose Save to keep the configuration as a .set file. Each line holds one parameter with its value and, for optimization, its start, step and stop and whether it was ticked.
It is not required, but if you drop it together with the XML, Orometra knows exactly which ranges you asked MT5 to test. It can then tell you how much of that space was really covered, which matters above all with the genetic algorithm, and the .set you download at the end carries all the EA’s parameters, not only the ones you optimized.
Check the files before analyzing them
- Open each XML in Excel or LibreOffice. You should see one row per pass, the metric columns and your parameters. A single cell or unreadable text means you did not export the results table.
- The optimization file has as many rows as passes MT5 ran; the forward one, fewer. If both have exactly the same number of rows and the same columns, you have probably exported the same table twice. Orometra detects it and tells you.
- Every pass in the forward file must also be in the optimization file, with the same number in the Pass column.
The mistakes that ruin the analysis
- Using the .opt file. MT5 keeps its own cache of results in the tester folder, but it is an internal format that only MT5 reads: always export to XML.
- Mixing files from different optimizations. The optimization and forward files must come from the same run: same EA version, symbol, timeframe, dates and ranges. If you change anything and optimize again, export both tables again. Orometra checks it with the Back Result column and warns you if they do not match.
- Exporting a single backtest instead of the optimization. A single test produces a report (HTML or Open XML) with one configuration, not the table of passes. That report is useful for something else: checking the chosen configuration on a period you have not used.
- Very large files. If the XML takes tens of megabytes, narrow the ranges or the number of parameters and optimize again: besides being slow, so many combinations make it easier for something to look good by pure chance.
Next step
Drop both files, and the .set if you have it, into Orometra. In seconds you see which configuration is stable, how much evidence backs it and a .set ready for MT5. Everything runs in your browser: your files never leave your computer.