Expert History Export - MetaTrader 4 Library | MT4 EA Download - MetaTrader 4 Resources
Added the ability to automatically export trading history after running an Expert Advisor in the Strategy Tester.
File saved in shared terminal folder public/files or in the terminal folder MQL4/Documents.
The file name is automatically generated or set manually when calling the method. exit()
History files can be used to simulate the same trading sequence on another trading server using EA Simple history receiver .
1. Instantiate the object in the global scope:
CExpertHistory ExpertHistory();
2. Add to function call OnTester() method call exit() :
doubleOnTester(void) {
...
ExpertHistory.Export();
...
1. Instantiate the object in the global scope:
String expert name = "SomeExpert";
String Expert Version = "1.00"; // String data separator = ","; // String decimal point = "."; // Not required
CExpertHistory expert history record (expert name, expert version, dataSeparator, decimal point);
2. Add functions OnInit() Any parameter name and value pair:
input doubleSL = 500;
Enter double TP=1000;
...
ExpertHistory.AddParam("symbol", Symbol());
ExpertHistory.AddParam("TP", TP);
ExpertHistory.AddParam("SL", SL);
...
3. Add to function call OnTester() method call exit() :
doubleOnTester(void) {
...
if(!MQLInfoInteger(MQL_OPTIMIZATION)) { // If you only want to save history in a single tester run ExpertHistory.Export();
}
...
}
in method exit() There are options:
Invalid export (
string export FileName = "", // The name of the file to be exported. If it is empty, it is generated based on the exportFileNameFormat parameter.
ENUM_HISTORY_EXPORT_FORMAT exportFormat = HEF_INI_FULL, // Export format. By default, in addition to transactions, the file // records account parameters, test period, maximum. Retracement etc.
ENUM_HISTORY_FILENAME_FORMAT exportFileNameFormat = HFF_FULL, // File name format. By default, the file name includes server name, test period, and maximum time. Retracement etc.
int commonFlag=FILE_COMMON // Save the file to the shared terminal folder. If equal to 0, save to a non-shared folder.
);
Attachment download
📎 experthistoryexample.mq4 (2.87 KB)
📎 experthistory.mqh (38.82 KB)
Source: MQL5 #38980
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •