if ( ! GlobalVariableSetOnCondition( "Start" + Symbol(), 10, 0 ) )
if ( reEntryCnt == 1 )
Alert( "Re-Entry detected for ", Symbol() );
return ( 0 );
Welcome to mql4.com forum,
Please use the SRC button when you post code. Thank you.
This time, I edited it for you.
This is difficult because you may or may not have discovered re-entrancy under something like extreme load, and that may or may not be your fundamental problem. I don't think that there's enough information to work with, and you need to show more of the code.
Taking just one example, if you have added the re-entrancy check in a hurry because you are desperate to fix the bug, it would be understandable if you have overlooked a code path where start() can exit without resetting the global variable. Or there could be a rare set of circumstances where you end up doing something like division by zero, causing MT4 to bail out of that call to start() without resetting the global variable. (If this happening, then you might also not be closing the Win32 mailslot handle, which could lead to problems in the long term.)
The only actual clue is your mention of "incorrect" levels. That sounds as though you might sometimes be doing a lengthy operation in start() before evaluating the price data, and the data then examined by the EA is stale and needs use of RefreshRates().
[...] you need to show more of the code.
[...] if you have added the re-entrancy check in a hurry because you are desperate to fix the bug, it would be understandable if you have overlooked a code path where start() can exit without resetting the global variable.
(Head banging on wall.)
I should know better, but that is exactly what I did. I have 2 early
exits from start(). One is when I have to retry a failed mailslot message send.
The other is my deferred initialization check. (Since I have to go back in the
price history, I need to allow the platform time to download the data. Thus I have
a “if not initialized and can’t initialize yet, then return without doing
So it seems that re-entrancy was a red herring and my fundamental problem remains.
The only lengthy operation in start() is my deferred initialization
and once that is successful, it is not run again. That initialization does have
to run through 4300 periods of past price data.
It is having failed so far in getting an actual clue to
localize the problem that has gotten me frustrated, desperate, and unable to
come up with a limited code extract containing the problem. The total
code base is only about 1200 lines, fairly straightforward, and doesn’t contain
any startling algorithms, but I’m not free to release it. I’ll have to think
about trimming off pieces and see how that affects behavior, but there isn't that much to begin with to trim off of.
To add comments, please log in or register