文章 "自定义交易历史表述并创建报告图表" - 页 5

 
是否有可能将测试人员的测试历史记录读入我的文件?不是从 EA,而是通过添加脚本?
 
ANG3110:
是否有可能将测试人员的测试历史记录读入我的文件?不是从智能交易系统,而是通过添加一个脚本?

是的,实际上就是一个脚本,它可以从整个终端读取历史记录,而不会将其分割成智能交易系统。事实上,我在文章中描述了完成所有工作的类,你可以使用它并编写自己的脚本。

 

我想在去初始化的优化过程中使用您的开发成果进行历史分析。

您能告诉我如何更好地将余额变化纳入一个数组吗?该工具只进行当前交易。

 
Aleksey Vyazmikin:

我想在去初始化时使用你们的开发成果进行优化过程中的历史分析。

您能告诉我如何更好地将余额变化纳入一个数组吗?该工具只进行当前交易。

为此,最好使用我第二篇文章 中的最终类。类 "ReportCreator

使用该类,我可以在 OnDeinit 中使用以下代码在机器人中上传优化报告:

//+------------------------------------------------------------------+
//|简短报告。mqh
//|2019 年 MetaQuotes 软件公司版权所有 | |
//|https://www.mql5.com ||
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#include "ReportCreator.mqh"
//+------------------------------------------------------------------+
//| 文件写入器|
//+------------------------------------------------------------------+
void writer(string fileName,string headder,string row)
  {
   bool isFile=FileIsExist(fileName,FILE_COMMON); // 标记文件是否存在
   int file_handle=FileOpen(fileName,FILE_READ|FILE_WRITE|FILE_CSV|FILE_COMMON|FILE_SHARE_WRITE|FILE_SHARE_READ); // 打开文件
   if(file_handle) // 如果文件已打开
     {
      FileSeek(file_handle,0,SEEK_END); // 将光标移至文件末尾
      if(!isFile) // 如果是新创建的文件 - 写入标题
         FileWrite(file_handle,headder);
      FileWrite(file_handle,row); // 写一条信息
      FileClose(file_handle); // 关闭文件
     }
  }
//+------------------------------------------------------------------+
//| 历史保护器|
//+------------------------------------------------------------------+
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)+";");
  }
//+------------------------------------------------------------------+
该代码位于一个单独的文件中,我通过 #include 将其连接到机器人。