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

 
mt4forum:

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?

It doesn't, but you screw up the interface thread and MT4 locks up . . . can't you do what you are doing in an EA ?
 
You all talk about infinite loops, but no one is curious what CreateHistory() does. According to the log output it appears only in the last start() run.
 
Ovo:
You all talk about infinite loops, but no one is curious what CreateHistory() does. According to the log output it appears only in the last start() run.
I assumed it was some kind of history saving function . . . if the OP wants to show it he will . . . I assume he doesn't and even if he does it's probably not going to help us help him. The fastest way is for him to post his code so someone can look at it with a fresh pair of eyes. . . .
 
RaptorUK:
I assumed it was some kind of history saving function . . . if the OP wants to show it he will . . . I assume he doesn't and even if he does it's probably not going to help us help him. The fastest way is for him to post his code so someone can look at it with a fresh pair of eyes. . . .

No problem, I wanted to point that infinite loop might not be the only reason for the terminal to hang. Especially if the script modifies some files.
 

mt4forum2013.11.16 11:14


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

Judging by your log file it looks like it was already in a loop. What happens after it gets to 8 ? Was it in a loop if it was how do you know it exited that loop ? Did it return to init() ?

You added Print("Start Started"); and it never showed up in the log file so it never entered the start() function. That suggests it never exited the init() function. Put more Print() statements and narrow it down.

 

First of all, thank you for the great interest, and sorry for my late response.

I will address the different comments in the following entries.

 
RaptorUK:
It doesn't, but you screw up the interface thread and MT4 locks up . . . can't you do what you are doing in an EA ?

I have run the program as EA. It either hangs as well or crashes MT4.

 
mt4forum:

I have run the program as EA. It either hangs as well or crashes MT4.

I think you need to post your code for anyone to be able to stand much of a chance of helping . . .
 
Ovo:
You all talk about infinite loops, but no one is curious what CreateHistory() does. According to the log output it appears only in the last start() run.

CreateHistory() does a lot of work. It loops through currency pairs and timeframes and generates offline charts.

But the log file shows that it finishes correctly.

 
SDC:

Judging by your log file it looks like it was already in a loop. What happens after it gets to 8 ? Was it in a loop if it was how do you know it exited that loop ? Did it return to init() ?

You added Print("Start Started"); and it never showed up in the log file so it never entered the start() function. That suggests it never exited the init() function. Put more Print() statements and narrow it down.

After it gets to 8 it returns correctly to init().

The following line in the log file shows that. "DebugMyInit return ..." is the last debug line in MyInit().

2013.11.15 12:33:22 Test reduced 395052: USDJPY M15 DebugMyInit return InitialMyInitCalls: 0 IndexCount: 8

I use my own print function to generate the log file. Print("Start Started") does not print to that log file.

The entry

2013.11.15 12:33:22 Test reduced 395052: USDJPY M15 DebugStart: last return in InitialGapFound

shows, that it exited the init() function.

If I can trust, that my debug function logs all the information correctly, then the log file tells us, that after the last run of start(),

start() is exited and is not called again. That's the problem.

Reason: