How to open cache optimization file (.opt), MT5
Hi,
Is there a way to open Metatrader 5 optimization cache file (folder -> tester/cache/) with another software and export the data in .csv format or another format different than .xml?
or
Is there a way to export optimization results in another format different than .xml?
Thanks!!
Im looking in a way to open the .opt file too but its not to export to a csv, I want to export a list of Inputs for specific passes
If yo use BackTest Kicker to do multiple tests in a row it will save the Cache and XML for Back and Forward optmization on the report folder.
Im looking in a way to open the .opt file too but its not to export to a csv, I want to export a list of Inputs for specific passes
Have a look at the code included with the recently released book "MQL5 Programming for Traders" -- https://www.mql5.com/en/book/
I haven't tried myself, but there is an OptReader.mqh header file that may help you... There's a vast library of useful classes/utilities & examples -- have a look at https://www.mql5.com/en/code/45596
Let me know how you get on, I'm kind of curious about what you're trying to do.
- www.mql5.com
It compiles but it never sees the .opt files in the directory.
#include <OptReader.mqh> // Removed 'input' keyword to allow modification string optDirectory; // Will be set dynamically input string csvDirectory = "C:\\pythonscript\\automatedbacktest\\Reports"; void OnStart() { // Set the directory for .opt files optDirectory = TerminalInfoString(TERMINAL_DATA_PATH) + "\\Tester\\cache\\"; string filePattern = "*.opt"; string optFile; // Single string to hold the file name string searchPattern = optDirectory + filePattern; // Correct pattern with directory long totalFiles = 0; // Variable to store the number of files found long fileHandle; // Use long for the file handle // Get a list of .opt files fileHandle = FileFindFirst(searchPattern, optFile); // Use a single string variable if (fileHandle != INVALID_HANDLE) { do { string optFilePath = optDirectory + optFile; // Correct path concatenation string baseFileName = StringSubstr(optFile, 0, StringLen(optFile) - 4); string csvFilePath = csvDirectory + "\\" + baseFileName + ".csv"; // Create an OptReader instance for the .opt file OptReader reader(optFilePath); // Pass the file path to the constructor // Export the data to a CSV file reader.export2CSV(csvFilePath); // Assuming export2CSV is a void function Print("Data exported to CSV for file: ", optFilePath); totalFiles++; // Increment the total files processed counter } while (FileFindNext(fileHandle, optFile)); // Corrected the loop condition FileFindClose(fileHandle); // Close the file search handle } else { Print("No .opt files found in the directory: ", optDirectory); } Print("Export completed. Total files processed: ", totalFiles); }
Hi,
Is there a way to open Metatrader 5 optimization cache file (folder -> tester/cache/) with another software and export the data in .csv format or another format different than .xml?
or
Is there a way to export optimization results in another format different than .xml?
Thanks!!