MT4专家顾问每次都运行错误的股票行情

时间:2018-10-28 20:35:33

标签: mt4

我有一个简单的脚本,该脚本将数据写入文件OnTick事件,但是我无法选择它将为哪个符号运行,如果我在终端机上激活了股票行情窗口(例如DE30),它仍然会打开EURUSD窗口并将这些数据写到文件中,重新编译无济于事。

#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason)
  {
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   //---
   //Nazwa pliku
   string  fileName = "D300_" + TimeToStr(TimeCurrent(),TIME_DATE);
   int replaced = StringReplace(fileName, ".", "");
   fileName = fileName + ".csv"; 
   //MessageBox(fileName);

   //Tworzenie pliku
   int handle;
   datetime dataOtwarciaPozycji = TimeCurrent();
   handle=FileOpen(fileName, FILE_CSV|FILE_READ|FILE_WRITE, ';');
   //MessageBox(Close[0]);

   //Zapis do pliku
   if(handle>0)
   {
   if(FileSeek(handle, 0, SEEK_END)) {
      string sekunda;
      sekunda = Seconds();

      if(StrToInteger(sekunda) < 10){
         sekunda = "0" + sekunda;
      }

      FileWrite(handle, TimeToStr(TimeCurrent())+":"+sekunda, Close[0] + ";" + Bid + ";" + Ask + ";" + Symbol());
      Print("appending to file");   
   }

   FileClose(handle);
   }
  }
//+------------------------------------------------------------------+

0 个答案:

没有答案