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

 

你好。

我正面临着一个丑陋的问题。

我的指标的start()函数 在调用return()后几经反复,没有再回来,也就是说,MT4挂在一个循环中,耗费CPU,没有再调用start()。

我想知道是否我破坏了函数的调用栈?

您认为我应该主要寻找什么原因?

我已经调试了一星期了。它有72页的代码。

我没有使用任何DLL调用,只有平面MQL。

谢谢你。

 
你没有从开始返回。你需要修正你的代码。获取dbgView,在每个函数的开始和返回处添加日志 调用,追踪你的无限循环。
 

我已经在记录调试信息了。

我看不到一个无限循环。

我在日志文件中看到的最后一件事是我在start()的最后一行中调用return()。

从那以后,start()就再也没有被触发过。

这一定是别的原因。

 
在哪里/如何记录?你不能使用Print/Alert,因为你挂了GUI线程,输出将不会被写入。
 

我知道,我在用我自己的PrintDebug()函数 与FileWrite()、FileFlush。

 

你认为,我打印调试信息的方式是否足够?

 
mt4forum:

我已经在记录调试信息了。

我看不到一个无限循环。

我在日志文件中看到的最后一件事是我在start()的最后一行中调用return()。

从那以后,start()就再也没有被触发过。

这一定是别的原因。


你是否在start()的第一行打印一些东西到日志?
 

是的,我正在记录第一行和最后一行。

我可以确定,我的记录方式没有遗漏任何记录信息吗?

 
mt4forum:

是的,我正在记录第一行和最后一行。

我可以确定,我的记录方式没有遗漏任何记录信息吗?

如果你不确定,就用一个标准的Print(),并检查 日志文件,而不仅仅是专家标签。......我们还没有看到你的日志记录方式。

你是否通过iCustom()调用使用任何指标? 如果是,也许它们占用了CPU周期。. .
 

这是我的日志函数。

void PrintDebug(int F, string DebugStr1, string DS2 = "", string DS3 = "", string DS4 = "", string DS5 = "", string DS6 = "", string DS7 = "", 
   string DS8 = "", string DS9 = "", string DS10 = "", string DS11 = "", string DS12 = "", string DS13 = "", string DS14 = "", string DS15 = "", 
   string DS16 = "", string DS17 = "", string DS18 = "", string DS19 = "", string DS20 = "")
{
   FileWrite(F, CommonIdentStr() + Blank + DebugStr1 + DS2 + DS3 + DS4 + DS5 + DS6 + DS7 + DS8 + DS9 + DS10 
               + DS11 + DS12 +DS13 + DS14 + DS15 + DS16 + DS17 + DS18 + DS19 + DS20);
   FileFlush(F);
}

这是我的start函数。

int start()
  {     
   int TFInd;
   int k;  
   
   if (CheckDebug(DebugStart, 2))
      {
         DebugStr = "DebugStart: " + "begin: " + " InitialGapFound: " + BoolToString(InitialGapFound);
         PrintDebug(DebugFile, DebugStr);
      }
   
   if (InitialGapFound)        
      {                                             
         if (TimeLocal() >= LastInitialGapCloseCheck + HistoryDownloadCheckInterval)                                  // zzz
            {
               LastInitialGapCloseCheck = TimeLocal();
               
               if (InitialHistoryGapClosed())
                  {
                     if (CheckDebug(DebugStart, 2))
                        {
                           DebugStr =  "DebugStart: " + " InitialHistoryGapClosed ";
                           PrintDebug(DebugFile, DebugStr);
                        }
                  
                     ReInit = true;
                     InitialGapFound = false;

                     MyInit();
                  }        
            }

         if (CheckDebug(DebugStart, 2))
            {
               DebugStr = "DebugStart: " + " last return in InitialGapFound";
               PrintDebug(DebugFile, DebugStr);
            } 
            
         return(OK);
      
      }  // if InitialGapFound

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

我正在记录开始和结束的时间。

函数CheckDebug()没有任何影响,因为它总是返回true。

下面是生成的日志文件。

你可以看到最后一条是 "DebugStart: last return in InitialGapFound",这是start()函数中执行的最后一条语句。

日志文件 的下一个条目 应该是 "DebugStart: begin:...",即start()函数的第一条语句。

但start()再也没有被触发。相反,MT4在一个循环中挂起。

我的程序逻辑中看不到任何循环。我没有使用DLLs,没有iCustom,...

2013.11.15 12:33:14 Test reduced 0: USDJPY M15 Debug Init() begin:
2013.11.15 12:33:14 Test reduced 0: USDJPY M15 DebugMyInit begin:
2013.11.15 12:33:14 Test reduced 0: USDJPY M15 Debug Init() return:
2013.11.15 12:33:14 Test reduced 0: USDJPY M15 DebugStart: begin: InitialGapFound:真
2013.11.15 12:33:14 Test reduced 0: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 12:33:15 测试减少395052:USDJPY M15 DebugStart:开始。 InitialGapFound:真
2013.11.15 12:33:15 测试减少 395052: USDJPY M15 DebugStart: InitialGapFound中的最后一次返回
2013.11.15 12:33:16 Test reduced 395052: USDJPY M15 DebugStart: begin: InitialGapFound:真
2013.11.15 12:33:16 Test reduced 395052: USDJPY M15 DebugStart: InitialHistoryGapClosed
2013.11.15 12:33:16 Test reduced 395052: USDJPY M15 DebugMyInit begin:
2013.11.15 12:33:16 Test reduced 395052: USDJPY M15 DebugMyInit InitialMyInitCalls:0 IndexCount:1 nach CreateHistory()
2013.11.15 12:33:17 Test reduced 395052: USDJPY M15 DebugMyInit InitialMyInitCalls:0 IndexCount:2 nach CreateHistory()
2013.11.15 12:33:18 Test reduced 395052: USDJPY M15 DebugMyInit InitialMyInitCalls:0 IndexCount:3 nach CreateHistory()
2013.11.15 12:33:19 Test reduced 395052: USDJPY M15 DebugMyInit InitialMyInitCalls:0 IndexCount:4 nach CreateHistory()
2013.11.15 12:33:20 Test reduced 395052: USDJPY M15 DebugMyInit InitialMyInitCalls:0 IndexCount:5 nach CreateHistory()
2013.11.15 12:33:21 Test reduced 395052: USDJPY M15 DebugMyInit InitialMyInitCalls:0 IndexCount:6 nach CreateHistory()
2013.11.15 12:33:22 Test reduced 395052: USDJPY M15 DebugMyInit InitialMyInitCalls:0 IndexCount:7 nach CreateHistory()
2013.11.15 12:33:22 Test reduced 395052: USDJPY M15 DebugMyInit return InitialMyInitCalls:0 IndexCount:8
2013.11.15 12:33:22 Test reduced 395052: USDJPY M15 DebugStart: last return in InitialGapFound

 
mt4forum:

这是我的日志函数。

这是我的start函数。

我正在记录开始和结束的时间。

函数CheckDebug()没有任何影响,因为它总是返回true。

下面是生成的日志文件。

你可以看到最后一条是 "DebugStart: last return in InitialGapFound",这是start()函数中执行的最后一条语句。

日志文件中的下一个条目应该是 "DebugStart: begin:...",即start()函数的第一条语句。

但start()再也没有被触发。相反,MT4在一个循环中挂起。


什么是可以在......。

      return(OK);


让我们假设你的调试导致了这个问题,请在start()运行中的变量声明后添加以下内容,并报告显示日志和你的日志摘录如上。

int start()
  {     
   int TFInd;
   int k;  
   
   Print("start():  started . . .");  // <-----  add this line here
   
   if (CheckDebug(DebugStart, 2))