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!!

 
I am trying that as well but did not figure it yet. How can you export in .xml format? because the file looks encrypted somehow
 
DDamasceno:

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!!

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 
 
NathanYsp #:
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.

MQL5 Programming for Traders – Source Codes from the Book. Part 7
MQL5 Programming for Traders – Source Codes from the Book. Part 7
  • www.mql5.com
The final seventh part of the book discusses the advanced capabilities of the MQL5 API, which will be useful when developing programs for MetaTrader 5. These include custom financial symbols, built-in economic calendar events, and general-purpose technologies such as networking, databases, and cryptography.
 
Anyone figure it out? 
 
TesterCache
TesterCache
  • www.mql5.com
Чтение/Запись opt-файлов оптимизационных кешей MT5-тестера
 
Any idea why this does not work?

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);
}


 
andy schlipf #:
Any idea why this does not work?

It compiles but it never sees the .opt files in the directory.

Only these files can be accessed: MQL5\Files\*.*

Reason: