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

 

start():

int start()
  {     
   int TFInd;
   int k;  
   
   Print("start():  started . . .");  
   
   if (CheckDebug(DebugStart, 2))
      {
         DebugStr = "DebugStart: " + "begin: " + " InitialGapFound: " + BoolToString(InitialGapFound);
         PrintDebug(DebugFile, DebugStr);
      }

...

OK is just #define OK 0

my log file:

2013.11.15 14:35:30 Test reduced 0: USDJPY M15 Debug Init() begin:
2013.11.15 14:35:30 Test reduced 0: USDJPY M15 DebugMyInit begin:
2013.11.15 14:35:30 Test reduced 0: USDJPY M15 Debug Init() return:
2013.11.15 14:35:30 Test reduced 0: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:30 Test reduced 0: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:30 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:31 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound
2013.11.15 14:35:32 Test reduced 1180990: USDJPY M15 DebugStart: begin: InitialGapFound: True
2013.11.15 14:35:32 Test reduced 1180990: USDJPY M15 DebugStart: InitialHistoryGapClosed
2013.11.15 14:35:32 Test reduced 1180990: USDJPY M15 DebugMyInit begin:
2013.11.15 14:35:32 Test reduced 1180990: USDJPY M15 DebugMyInit InitialMyInitCalls: 0 IndexCount: 1 nach CreateHistory()
2013.11.15 14:35:33 Test reduced 1180990: USDJPY M15 DebugMyInit InitialMyInitCalls: 0 IndexCount: 2 nach CreateHistory()
2013.11.15 14:35:34 Test reduced 1180990: USDJPY M15 DebugMyInit InitialMyInitCalls: 0 IndexCount: 3 nach CreateHistory()
2013.11.15 14:35:35 Test reduced 1180990: USDJPY M15 DebugMyInit InitialMyInitCalls: 0 IndexCount: 4 nach CreateHistory()
2013.11.15 14:35:35 Test reduced 1180990: USDJPY M15 DebugMyInit InitialMyInitCalls: 0 IndexCount: 5 nach CreateHistory()
2013.11.15 14:35:36 Test reduced 1180990: USDJPY M15 DebugMyInit InitialMyInitCalls: 0 IndexCount: 6 nach CreateHistory()
2013.11.15 14:35:37 Test reduced 1180990: USDJPY M15 DebugMyInit InitialMyInitCalls: 0 IndexCount: 7 nach CreateHistory()
2013.11.15 14:35:37 Test reduced 1180990: USDJPY M15 DebugMyInit return InitialMyInitCalls: 0 IndexCount: 8
2013.11.15 14:35:37 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound


The MT4 log file doesn't show anything. Print() does not work in such a case when MT4 hangs, because the MT4 log file does not get flushed. That's why I'm using my own log function.

see also

WHRoeder2013.11.14 19:27#

Logging where/how? You can NOT use Print/Alert because you are hanging the GUI thread, the output will not be written.

MT4 log file:

13:38:00 GA_Pivot Points DE30.Z,M15: initialized
13:38:00 $CH_Stochastic Copyright Dec2009 DE30.Z,M15: initialized
14:35:05 GA_Daily Range Lines V1.3 _US30,M15: deinitialized
14:35:05 GA_Daily Range Lines V1.3 _US30,M15: uninit reason 1
14:35:05 GA_MTF MAs 1 V1.4 _US30,M15: uninit reason 1
14:35:05 GA_MTF MAs 2 V1.4 _US30,M15: uninit reason 1
14:35:05 GA_Pivot Points _US30,M15: deinitialized
14:35:05 GA_Pivot Points _US30,M15: uninit reason 1
14:35:05 $CH_Stochastic Copyright Dec2009 _US30,M15: deinitialized
14:35:05 $CH_Stochastic Copyright Dec2009 _US30,M15: uninit reason 1
14:35:05 GA_Daily Range Lines V1.3 _US30,M15: removed
14:35:05 GA_MTF MAs 1 V1.4 _US30,M15: removed
14:35:05 GA_MTF MAs 2 V1.4 _US30,M15: removed
14:35:05 GA_Pivot Points _US30,M15: removed
14:35:05 $CH_Stochastic Copyright Dec2009 _US30,M15: removed
14:35:05 GA_MTF MAs 1 V1.4 _US30,M15: uninit reason 1
14:35:05 GA_MTF MAs 2 V1.4 _US30,M15: uninit reason 1
14:35:05 GA_Pivot Points _US30,M15: deinitialized
14:35:05 GA_Pivot Points _US30,M15: uninit reason 1
14:35:05 $CH_Stochastic Copyright Dec2009 _US30,M15: deinitialized
14:35:05 $CH_Stochastic Copyright Dec2009 _US30,M15: uninit reason 1
14:35:05 GA_MTF MAs 1 V1.4 _US30,M15: removed
14:35:05 GA_MTF MAs 2 V1.4 _US30,M15: removed
14:35:05 GA_Pivot Points _US30,M15: removed
14:35:05 $CH_Stochastic Copyright Dec2009 _US30,M15: removed
14:35:05 GA_MTF MAs 1 V1.4 _EUR50,Daily: uninit reason 1
14:35:05 GA_MTF MAs 2 V1.4 _EUR50,Daily: uninit reason 1
14:35:05 GA_Pivot Points _EUR50,Daily: deinitialized
14:35:05 GA_Pivot Points _EUR50,Daily: uninit reason 1
14:35:05 $CH_Stochastic Copyright Dec2009 _EUR50,Daily: deinitialized
14:35:05 $CH_Stochastic Copyright Dec2009 _EUR50,Daily: uninit reason 1
14:35:05 GA_MTF MAs 1 V1.4 _EUR50,Daily: removed
14:35:05 GA_MTF MAs 2 V1.4 _EUR50,Daily: removed
14:35:05 GA_Pivot Points _EUR50,Daily: removed
14:35:05 $CH_Stochastic Copyright Dec2009 _EUR50,Daily: removed
14:35:05 GA_MTF MAs 1 V1.4 _DE30,M15: uninit reason 1
14:35:05 GA_MTF MAs 2 V1.4 _DE30,M15: uninit reason 1
14:35:05 GA_Pivot Points _DE30,M15: deinitialized
14:35:05 GA_Pivot Points _DE30,M15: uninit reason 1
14:35:05 $CH_Stochastic Copyright Dec2009 _DE30,M15: deinitialized
14:35:05 $CH_Stochastic Copyright Dec2009 _DE30,M15: uninit reason 1
14:35:05 GA_MTF MAs 1 V1.4 _DE30,M15: removed
14:35:05 GA_MTF MAs 2 V1.4 _DE30,M15: removed
14:35:05 GA_Pivot Points _DE30,M15: removed
14:35:05 $CH_Stochastic Copyright Dec2009 _DE30,M15: removed
14:35:05 GA_MTF MAs 1 V1.4 DE30.Z,M15: uninit reason 1
14:35:05 GA_MTF MAs 2 V1.4 DE30.Z,M15: uninit reason 1
14:35:05 GA_Pivot Points DE30.Z,M15: deinitialized
14:35:05 GA_Pivot Points DE30.Z,M15: uninit reason 1
14:35:05 $CH_Stochastic Copyright Dec2009 DE30.Z,M15: deinitialized
14:35:05 $CH_Stochastic Copyright Dec2009 DE30.Z,M15: uninit reason 1
14:35:05 GA_MTF MAs 1 V1.4 DE30.Z,M15: removed
14:35:05 GA_MTF MAs 2 V1.4 DE30.Z,M15: removed
14:35:05 GA_Pivot Points DE30.Z,M15: removed
14:35:05 $CH_Stochastic Copyright Dec2009 DE30.Z,M15: removed

 
mt4forum:

start():

OK is just #define OK 0

OK

The MT4 log file doesn't show anything. Print() does not work in such a case when MT4 hangs, because the MT4 log file does not get flushed. That's why I'm using my own log function.

see also

WHRoeder2013.11.14 19:27#

Logging where/how? You can NOT use Print/Alert because you are hanging the GUI thread, the output will not be written
Print() will work before the hang . . . . if you stop EAs running, click the EA button, shouldn't the log file then flush ? then you would be able to see the last print . . . or change it to a Comment() and clear the comment at the end of start() with Comment("");
 

I'm running the program as an indicator.

To stop it, I have to kill the MT4 terminal process.

I've inserted comment() as you suggested.

The comment doesn't appear on the chart.

 
         if (TimeLocal() >= LastInitialGapCloseCheck + HistoryDownloadCheckInterval)                                  // zzz
Why are you calling TimeLocal That's your machine time (in your TZ,) not your broker time, not the tester's time. Try TimeCurrent() both places.
 

I know, I'm using it just to check, how much time has elapsed before I do some checking again.

In this case I could use any time function as long as I'm always using the same.

That's not the problem.

Is it possible that I am somehow destroying the function call stack of the start() function?

 
mt4forum: In this case I could use any time function as long as I'm always using the same. That's not the problem.
It is a problem if you ever want to use the tester/optimizer.
 
mt4forum:

I'm running the program as an indicator.

Are you decelerating the interface thread ?
 
RaptorUK:
Are you decelerating the interface thread ?

What do you mean by that?

 
mt4forum:

What do you mean by that?

In an Indicator you can't Sleep() you can't use MessageBox() or if your code just takes a long time in a loop . . .

"The function cannot be called from custom indicators since they are executed within interface thread and may not decelerate it."
 

No, I don't use sleep() or messagebox(), but I do a lot of work in the function MyInit(), which takes about 5 seconds.

You can see that in the log file:

2013.11.15 14:35:32 Test reduced 1180990: USDJPY M15 DebugStart: InitialHistoryGapClosed
2013.11.15 14:35:32 Test reduced 1180990: USDJPY M15 DebugMyInit begin: <---------- work starts
2013.11.15 14:35:32 Test reduced 1180990: USDJPY M15 DebugMyInit InitialMyInitCalls: 0 IndexCount: 1 nach CreateHistory()
2013.11.15 14:35:33 Test reduced 1180990: USDJPY M15 DebugMyInit InitialMyInitCalls: 0 IndexCount: 2 nach CreateHistory()
2013.11.15 14:35:34 Test reduced 1180990: USDJPY M15 DebugMyInit InitialMyInitCalls: 0 IndexCount: 3 nach CreateHistory()
2013.11.15 14:35:35 Test reduced 1180990: USDJPY M15 DebugMyInit InitialMyInitCalls: 0 IndexCount: 4 nach CreateHistory()
2013.11.15 14:35:35 Test reduced 1180990: USDJPY M15 DebugMyInit InitialMyInitCalls: 0 IndexCount: 5 nach CreateHistory()
2013.11.15 14:35:36 Test reduced 1180990: USDJPY M15 DebugMyInit InitialMyInitCalls: 0 IndexCount: 6 nach CreateHistory()
2013.11.15 14:35:37 Test reduced 1180990: USDJPY M15 DebugMyInit InitialMyInitCalls: 0 IndexCount: 7 nach CreateHistory()
2013.11.15 14:35:37 Test reduced 1180990: USDJPY M15 DebugMyInit return InitialMyInitCalls: 0 IndexCount: 8 <---------- work ends
2013.11.15 14:35:37 Test reduced 1180990: USDJPY M15 DebugStart: last return in InitialGapFound

But why would that make MT4 go in a loop after that?