avatar
GHI LAI BAO CAO BACK TEST

Guest 29 21st Feb, 2021

CPP 2.45 KB
                                           
                         //==================
void deinit()
  {
   if(IsTesting()|| IsOptimization())
     {
      RecordReport();
     }
  }


//+------------------------------------------------------------------+
void RecordReport()
  {
//if(RecReport==0) {return;}
   if(OrdersHistoryTotal() == 0)
      return;

// double SL_Pips_ = Stoploss_pip/PointConvert;
// double TP_Pips_ = Takeprofit_pip/PointConvert;

//====== Tao ten file va Ten truong
//====== Kiem tra xem file da ton tai chua
   string File_Name = "BOT win "+Symbol()+"_"+DoubleToStr(sl_point,0)+"_"+DoubleToStr(tp_point,0)+"_"+"_M"+Period()+".csv";

   int handle_ =FileOpen(File_Name, FILE_CSV|FILE_WRITE, ',');
   if(handle_>0)
     {
      FileSeek(handle_, 0, SEEK_END);
      FileWrite(handle_,"Symbol,OpenTime,CloseTime,Type,Profit,Hour,Adx,RSI");

      //====== Khai bao ======
      string   OpenTime,CloseTime,Hour_;
      double   Profit;//,Lots,H_Pip,L_Pip,C_Pip;
      double Adx,rsi;//
      int CandleShift;
      int dayshift;
      int h4shift;

      //====== Start recording ================
      for(int i=0; i <= OrdersHistoryTotal(); i++)
        {
         if(!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
            continue;
         if(OrderType() != OP_BUY && OrderType() != OP_SELL)
            continue;

         //========== Premium data ===================
         OpenTime    = TimeToStr(OrderOpenTime(),TIME_DATE|TIME_SECONDS);
         Hour_       = StringSubstr(OpenTime,11,2);
         CloseTime   = TimeToStr(OrderCloseTime(),TIME_DATE|TIME_SECONDS);
         Profit      = OrderProfit()+OrderCommission()+OrderSwap();

         CandleShift = iBarShift(OrderSymbol(),0,OrderOpenTime());
         dayshift = iBarShift(OrderSymbol(),PERIOD_D1,OrderOpenTime());
         h4shift = iBarShift(OrderSymbol(),PERIOD_H4,OrderOpenTime());

         Adx = iADX(OrderSymbol(),PERIOD_D1,14,PRICE_CLOSE,MODE_MAIN,dayshift);
         rsi = iRSI(OrderSymbol(),0,14,PRICE_CLOSE,CandleShift);
         //========== add data to the end of file ==========
         FileSeek(handle_, 0, SEEK_END);
         FileWrite(handle_, Symbol(),OpenTime,CloseTime,OrderType(),Profit,Hour_,Adx,rsi);
        }// end for
      FileClose(handle_);
      handle_=0;
     }
  }
//+==================================================================+
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data

Comments

Authentication required

You must log in to post a comment.

Log in
    There are no comments yet.
Tắt Quảng Cáo [X]
Tắt Quảng Cáo [X]