MT4挂起,没有再次调用start()。 - 页 4

 

我同意Raptor的观点,只有当你发布相关的代码时,才会有人真正能够提供帮助,否则就像在黑暗中拍摄一样。

 

我很抱歉,我不能发布代码。它有72页,是一个产品 的代码,我将发布。

同时,我已经实现了WHRoeder在他的第一个答案中建议的日志调用。

编写调试信息,可以通过微软的dbgView查看。

这个调试信息和我自己的调试信息完全一样,这表明。

我们可以相信我们在日志文件中看到的东西。

现在,日志文件告诉我们,start()被退出了,但是没有再被触发。

这似乎与在start()中调用的CreateHistory()的工作量有关。

当我在init()中调用同样的CreateHistory()时,完成的工作量完全相同,没有任何问题。

我们可以请MT4的开发人员来看看这个问题吗?

我在哪里可以找到关于MT4崩溃的进一步信息(我的指标的EA版本会让MT4崩溃)?

我在windows事件查看器中没有看到任何信息。

 

当我说张贴相关的代码时,我并不是说所有的代码,我的意思是,自从上次成功运行后,你对它做了什么修改或添加?我想你没有直接写72页的代码而没有进行任何测试......

 

我所改变的是:我把CreateHistory()从init()移到start()。

目前的情况是这样的。

当我在start中调用CreateHistory()时,没有任何延迟:工作正常。

当我在启动时调用CreateHistory(),延迟>=1秒。MT4挂起。

然而,挂起的不是CreateHistory(),而是start()函数

下面是start()的代码。

int start()
  {     
   int TFInd;
   int k;  
   
   if (CheckDebug(DebugStart, 2))
      {
         DebugStr = "DebugStart: " + "begin ---------------------------------------: ";
         PrintDebug(DebugFile, DebugStr);
      }

      
   for (IndexCount = 1; IndexCount <= MaxIndices; IndexCount++)
      {
         if (CheckDebug(DebugStart, 2))
            {
               DebugStr = "DebugStart: " + "in loop +++++++++++++: "+ "IndexCount: "+ IndexCount;
               PrintDebug(DebugFile, DebugStr);
            }              
      
         if (MyCurrencyIndices[IndexCount] == 0)
            break;

         CurrencyIndex = MyCurrencyIndices[IndexCount];             

         CurrencyIndexStr = Prefix + CurrencyNames[CurrencyIndex];
                 
         if (!HistoryCreated[CurrencyIndex] && (TimeLocal() >= IndiStartTime + 0))                                                  // yyy
            {                     
               FileSeek(FileHandle[CurrencyIndex, TimeFrameM15] , HeaderFilePointer[CurrencyIndex, TimeFrameM15] , SEEK_SET);
               FileSeek(FileHandle[CurrencyIndex, TimeFrameH1] , HeaderFilePointer[CurrencyIndex, TimeFrameH1] , SEEK_SET);
               FileSeek(FileHandle[CurrencyIndex, TimeFrameH4] , HeaderFilePointer[CurrencyIndex, TimeFrameH4] , SEEK_SET);
               FileSeek(FileHandle[CurrencyIndex, TimeFrameD1] , HeaderFilePointer[CurrencyIndex, TimeFrameD1] , SEEK_SET);

               CreateHistory();
               HistoryCreated[CurrencyIndex] = true;    
            }                           
      }  

   if (CheckDebug(DebugStart, 2))
      {
         DebugStr = "DebugStart: " + "returning ...";
         PrintDebug(DebugFile, DebugStr);
      }
                          
   return(0);
  }

下面是两个日志文件。

一个是上面的代码,TimeLocal() >= IndiStartTime + 0(工作正常),一个是上面的代码,TimeLocal() >= IndiStartTime + 1(挂起)。

在最后一种情况下,CreateHistory()执行并正确返回。

它只在start()中被调用一次。

在start()中没有做其他事情,但start()没有被MT4再次调用,MT4挂起,占用CPU。

CreateHistory()触发了我80%的代码。

我不能发布它。

0秒延迟的日志文件。

2013.12.04 12:34:10 测试减少。USDJPY M15 Debug Init() begin:
2013.12.04 12:34:10 测试减少。USDJPY M15 Debug Init() return:
2013.12.04 12:34:10 测试减少。USDJPY M15 DebugStart: begin ---------------------------------------:
2013.12.04 12:34:10 测试减少。USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:1 <----------- CreateHistory()被立即调用
2013.12.04 12:34:10 测试减少。USDJPY M15 Debug CreateHistory TimeFrame(), start: CurrencyIndex:1 TF: 1 ShiftsArray[1, TF]: 4996 TheShift: 0
2013.12.04 12:34:10 测试减少。USDJPY M15 Debug CreateHistory TimeFrame(), final return: CurrencyIndex:1 TF: 1
2013.12.04 12:34:10 测试减少。USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:2
2013.12.04 12:34:10 测试减少。USDJPY M15 DebugStart: 返回 ...
2013.12.04 12:34:11 测试减少。USDJPY M15 DebugStart: begin ---------------------------------------: <------------ start() gets triggered repeatedly.
2013.12.04 12:34:11 测试减少。USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:1
2013.12.04 12:34:11 测试减少。USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:2
2013.12.04 12:34:11 测试减少。USDJPY M15 DebugStart: 返回 ...
2013.12.04 12:34:11 测试减少。USDJPY M15 DebugStart: begin ---------------------------------------:
2013.12.04 12:34:11 测试减少。USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:1
2013.12.04 12:34:11 测试减少。USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:2
2013.12.04 12:34:11 测试减少。USDJPY M15 DebugStart: 返回 ...

延迟1秒的日志文件。

2013.12.04 12:32:17 Test reduced 0: USDJPY M15 Debug Init() begin:
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 Debug Init() return:
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: begin ---------------------------------------:
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:1
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:2
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: returning ...
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: begin ---------------------------------------:
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:1
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:2
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: returning ...
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: begin ---------------------------------------:
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:1
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:2
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: returning ...
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: begin ---------------------------------------:
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:1
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:2
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: returning ...
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: begin ---------------------------------------:
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:1
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:2
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: returning ...
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: begin ---------------------------------------:
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:1
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:2
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: returning ...
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: begin ---------------------------------------:
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:1
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:2
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: returning ...
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: begin ---------------------------------------:
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:1
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:2
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: returning ...
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: begin ---------------------------------------:
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:1
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:2
2013.12.04 12:32:17 Test reduced 0: USDJPY M15 DebugStart: returning ...
2013.12.04 12:32:18 Test reduced 0: USDJPY M15 DebugStart: begin ---------------------------------------:
2013.12.04 12:32:18 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:1
2013.12.04 12:32:18 Test reduced 0: USDJPY M15 Debug CreateHistoryTimeFrame(), start: CurrencyIndex:1 TF: 1 ShiftsArray[1, TF]: 4996 TheShift: 0 <----------- after 1 sec CreateHistory() is called
2013.12.04 12:32:18 Test reduced 0: USDJPY M15 Debug CreateHistory TimeFrame(), final return: CurrencyIndex:1 TF: 1
2013.12.04 12:32:18 Test reduced 0: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount:2
2013.12.04 12:32:18 Test reduced 0: USDJPY M15 DebugStart: returning ... <---------- start() is never triggerd again

 
我觉得像在玩捉迷藏。现在我非常怀疑你的 CreateHistory() 函数 重复地写到活的.hst文件。我说的对吗?
 

CreateHistory()创建离线图表,写到.hst文件。

它不会写到实时的.hst文件中。

 
mt4forum:

CreateHistory()创建离线图表,写到.hst文件。

它不会写到实时的.hst文件中。

你如何确保是这样的情况?
 
RaptorUK:
你如何确保是这种情况?

   CurrencyIndexStr = "CI_EUR";  

   FileName = CurrencyIndexStr + ThePeriod + ".hst";
   FileHandle = FileOpenHistory(FileName, FILE_BIN|FILE_WRITE);  

没有名为CI_EUR的MT4工具。

 
mt4forum:

没有名为CI_EUR的MT4工具。

確定