MT4 hangs, doesn't call start() again - page 4

 

I agree with Raptor, the only way anyone is really going to be able to help is if you post the relevent code otherwise it's like just taking shots in the dark.

 

I'm sorry, I can't post the code. It's 72 pages and it's the code of a product, which I will release.

In the meantime I've implemented the log calls, which WHRoeder suggested in his first answer,

writing debug information, that can be viewed by Microsoft's dbgView.

This debug information is exactly the same as my own debug information, which shows,

that we can trust what we see in the log files.

Now, the log file tells us, that start() is exited, but does not get triggered anymore.

It seems that this has to do with the amount of work being done in CreateHistory(), which is called within start().

When I call the same CreateHistory() in init(), exactly the same amount of work gets done without any problem.

Can we involve an MT4 developer, to look at this?

Where can I find further information about an MT4 crash (the EA version of my indicator crashes MT4)?

I could not see anything in the windows event viewer.

 

When I said post the relevent code I didnt mean all of it, I meant what did you change or add to it since the last time it ran successfully ? I assume you didnt write 72 pages of straight code without any testing along the way ...

 

What I've changed is: I've moved CreateHistory() from init() to start().

The current situation is as follows:

When I call CreateHistory() in start without any delay: works fine.

When I call CreateHistory() in start with a delay >= 1 sec: MT4 hangs.

However, it's not CreateHistory(), which hangs, it's the start() function.

Here's the code for 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);
  }

Below are 2 log files:

one for the code above with TimeLocal() >= IndiStartTime + 0 (works ok), one for the code above with TimeLocal() >= IndiStartTime + 1 (hangs).

In the last case CreateHistory() performs and returns correctly.

It is called only once within start().

Nothing else is being done in start(), nevertheless start() is never called again by MT4 and MT4 hangs, eating up CPU.

CreateHistory() triggers 80% of my code.

I can't post it.

log file for 0 sec delay:

2013.12.04 12:34:10 Test reduced: USDJPY M15 Debug Init() begin:
2013.12.04 12:34:10 Test reduced: USDJPY M15 Debug Init() return:
2013.12.04 12:34:10 Test reduced: USDJPY M15 DebugStart: begin ---------------------------------------:
2013.12.04 12:34:10 Test reduced: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount: 1 <----------- CreateHistory() is called immediately
2013.12.04 12:34:10 Test reduced: USDJPY M15 Debug CreateHistoryTimeFrame(), start: CurrencyIndex: 1 TF: 1 ShiftsArray[1, TF]: 4996 TheShift: 0
2013.12.04 12:34:10 Test reduced: USDJPY M15 Debug CreateHistoryTimeFrame(), final return: CurrencyIndex: 1 TF: 1
2013.12.04 12:34:10 Test reduced: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount: 2
2013.12.04 12:34:10 Test reduced: USDJPY M15 DebugStart: returning ...
2013.12.04 12:34:11 Test reduced: USDJPY M15 DebugStart: begin ---------------------------------------: <------------ start() gets triggered repeatedly
2013.12.04 12:34:11 Test reduced: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount: 1
2013.12.04 12:34:11 Test reduced: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount: 2
2013.12.04 12:34:11 Test reduced: USDJPY M15 DebugStart: returning ...
2013.12.04 12:34:11 Test reduced: USDJPY M15 DebugStart: begin ---------------------------------------:
2013.12.04 12:34:11 Test reduced: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount: 1
2013.12.04 12:34:11 Test reduced: USDJPY M15 DebugStart: in loop +++++++++++++: IndexCount: 2
2013.12.04 12:34:11 Test reduced: USDJPY M15 DebugStart: returning ...

log file for 1 sec delay:

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 CreateHistoryTimeFrame(), 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

 
I feel like playing hide & seek. Right now I am very suspicious that your CreateHistory() function repeatedly writes to the live .hst files. Am I right?
 

CreateHistory() creates offline charts, writing to .hst files.

It does NOT write to the live .hst files.

 
mt4forum:

CreateHistory() creates offline charts, writing to .hst files.

It does NOT write to the live .hst files.

How do you ensure this is the case ?
 
RaptorUK:
How do you ensure this is the case ?

   CurrencyIndexStr = "CI_EUR";  

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

There is no MT4 instrument named CI_EUR.

 
mt4forum:

There is no MT4 instrument named CI_EUR.

OK
Reason: