Discussion of article "Custom presentation of trading history and creation of report diagrams" - page 5

 
Is it possible to read the tester's test history into my files? Not from the EA, but by adding a script?
 
ANG3110:
Is it possible to read the tester's test history into my files? Not from an Expert Advisor, but by adding a script?

Yes, actually it is a script that reads the history from the whole terminal without splitting it into Expert Advisors. Actually in the article I described the class that does all the work, you can use it and write your own script.

 

I want to use your development for history analysis during optimisation at the moment of deinitialisation.

Could you please tell me how to do it better to get the balance change into one array? The instrument is traded only current.

 
Aleksey Vyazmikin:

I want to use your development for history analysis during optimisation at the time of deinitialisation.

Could you please tell me how to do it better to get the balance change into one array? The instrument is traded only current.

For this it is better to use the finalised class from my second article. Class "ReportCreator"

Using this class, I use this code in OnDeinit to upload optimisation reports in my robots:

.
//+------------------------------------------------------------------+
//|ShortReport.mqh |
//| Copyright 2019, MetaQuotes Software Corp. | |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#include "ReportCreator.mqh"
//+------------------------------------------------------------------+
//| File writer|
//+------------------------------------------------------------------+
void writer(string fileName,string headder,string row)
  {
   bool isFile=FileIsExist(fileName,FILE_COMMON); // Flag whether the file exists
   int file_handle=FileOpen(fileName,FILE_READ|FILE_WRITE|FILE_CSV|FILE_COMMON|FILE_SHARE_WRITE|FILE_SHARE_READ); // Open the file
   if(file_handle) // If the file is opened
     {
      FileSeek(file_handle,0,SEEK_END); // Move the cursor to the end of the file
      if(!isFile) // If it is a newly created file - write the title
         FileWrite(file_handle,headder);
      FileWrite(file_handle,row); // Write a message
      FileClose(file_handle); // Close the file
     }
  }
//+------------------------------------------------------------------+
//| History saver|
//+------------------------------------------------------------------+
void SaveReportToFile(string fileName)
  {
   if(FileIsExist(fileName,FILE_COMMON))
     {
      FileDelete(fileName,FILE_COMMON);
     }

   DealDetales history[];
   CDealHistoryGetter dealGetter;
   dealGetter.getDealsDetales(history,0,TimeCurrent());

   CReportCreator reportCreator;
   reportCreator.Create(history,0);

   TotalResult totalResult;
   reportCreator.GetTotalResult(totalResult);

   int total= ArraySize(history);
   for(int i=0;i<total;i++)
     {
      writer(fileName,
             "Symbol;DT open;Day open;DT close;Day close;Volume;Long/Short;Price in;Price out;PL for one lot;PL for deal;Open comment;Close comment;",
             history[i].symbol+";"+
             TimeToString(history[i].DT_open) + ";" +
             EnumToString(history[i].day_open) + ";" +
             TimeToString(history[i].DT_close) + ";" +
             TimeToString(history[i].day_close) + ";" +
             DoubleToString(history[i].volume)+";"+
             (history[i].isLong ? "Long" : "Short")+";"+
             DoubleToString(history[i].price_in) + ";" +
             DoubleToString(history[i].price_out) + ";" +
             DoubleToString(history[i].pl_oneLot) + ";" +
             DoubleToString(history[i].pl_forDeal) + ";" +
             history[i].open_comment + ";" +
             history[i].close_comment + ";");
     }

   writer(fileName,"","===========================================================================================================================================");
   writer(fileName,"","PL;"+DoubleToString(totalResult.total.PL)+";");
   writer(fileName,"","Recovery factor;"+DoubleToString(totalResult.total.recoveryFactor)+";");
   writer(fileName,"","Profit factor;"+DoubleToString(totalResult.total.profitFactor)+";");
   writer(fileName,"","Draw Down in percent;"+DoubleToString(totalResult.total.maxDrawdown.inPercents)+";");
   writer(fileName,"","Draw Down by pl;"+DoubleToString(totalResult.total.maxDrawdown.byPL)+";");
   writer(fileName,"","Draw Down for a deal;"+DoubleToString(totalResult.total.maxDrawdown.forDeal)+";");
  }
//+------------------------------------------------------------------+
This code is in a separate file which I connect to the robot via #include.