1,000,000$ 交易计划
以量化交易为生
//+------------------------------------------------------------------+
//|                                                      TickLog.mq4 |
//|                                                          外汇团荣誉出品 |
//|                                       https://www.waihuituan.com |
//+------------------------------------------------------------------+
#property copyright "外汇团荣誉出品"
#property link      "https://www.waihuituan.com"
#property version   "1.00"
#property strict
extern string logformat = "{year}/{mon}/{day} {hour}:{min}:{sec} {bid} {ask}";
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
      // 时间
      MqlDateTime curtime;
      TimeCurrent(curtime);
      string year = StringFormat("%d" ,curtime.year);
      string mon = StringFormat("%02d" ,curtime.mon);
      string day = StringFormat("%02d" ,curtime.day);
      string hour = StringFormat("%02d" ,curtime.hour);
      string min = StringFormat("%02d" ,curtime.min);
      string sec = StringFormat("%02d" ,curtime.sec);
      // 货币对
      string symbol = Symbol();
      // Ask Bid
      string myask = DoubleToString(Ask,Digits());
      string mybid = DoubleToString(Bid,Digits());
      string record = logformat;
      StringReplace(record, "{symbol}", symbol);
      StringReplace(record, "{year}", year);
      StringReplace(record, "{mon}", mon);
      StringReplace(record, "{day}", day);
      StringReplace(record, "{hour}", hour);
      StringReplace(record, "{min}", min);
      StringReplace(record, "{sec}", sec);
      StringReplace(record, "{ask}", myask);
      StringReplace(record, "{bid}", mybid);
      ResetLastError();
      string filename = "www.waihuituan.com\\" + symbol + "\\" +year + mon + ".csv";
      int filehandle=FileOpen(filename ,FILE_READ|FILE_WRITE|FILE_TXT);
      if(filehandle!=INVALID_HANDLE)
      {
         FileSeek(filehandle,0,SEEK_END);
         FileWrite(filehandle, record);
         FileClose(filehandle);
      }
      else {
         Print("Operation FileOpen failed, error ",GetLastError());
      }
  }

发表回复 取消回复