Error number 6 - page 29

 
logs sent. <br / translate="no"> Where should I put this code?
while(!IsStopped() && !IsTradeAllowed()) Sleep(1000); GlobalVariableSet(strTradeSemaphore, 0.0);


at the exit of the start function
 
Tried Sleep()
Up to 100000 with no visible improvement

Replaced by
if(!IsTesting()) { Sleep(1000); GlobalVariableSet(strTradeSemaphore, 0.0); }


at

while(!IsStopped() && !IsTradeAllowed()) Sleep(1000); GlobalVariableSet(strTradeSemaphore, 0.0);



Same pepper.
Error 146.

 
After a while, on second thought it turned out that there is an exact method. I will try to formulate it<br/ translate="no">
while(!IsStopped() && !IsTradeAllowed()) Sleep(1000); GlobalVariableSet(strTradeSemaphore, 0.0);


i.e. we ourselves are waiting for our own trade context to be released

and in general, this is an extremely strange situation. after conducting a trade operation, the context is released instantly. otherwise it would be impossible to close positions in a loop



Once again.

The code above will cause the Expert Advisor to hang, if the trade flag has been cleared.
This will cause the trade to stop altogether, because no one will signal the semaphore. This situation is at least somehow controllable, because the flag can only be removed manually.
Worse is the case of the semaphore. GlobalVariableSet can fall on another EA, when the latter closes the semaphore. As the result, several EAs will try to trade at the same time.
As you can see, developers do not understand asynchronous processes inside the terminal. And this misunderstanding is exported into the forum.
No wonder that fatal errors, such as the one discussed here, occur and these errors cannot be fixed.

Why give damaging advice?
 
Why give вредные advice?

The assumption is that if the advisor has reached this point, then the trading flag stands!
 
Зачем давать вредные советы?

the assumption is that if the EA has reached this point, then the trading flag is up!

What is the basis for this assumption? When assumptions do not match reality, unexpected errors occur.
The flag is nothing.
Synchronisation, mutexes, shared resources - the problem is real. It is nonsense to suggest that you solve it with user-level global variables. Especially since the example is unworkable.
 
Starting from 12 o'clock last night, experts were working on MQ-demo and Alpari-demo. During the whole time there was no error 128 either, on Alpari there was one error 6 (ping error), and on both - several old ticks. Orders worked without errors. Build 1.8.3 of 05.10. Maybe it's something else? For example, peculiarities of connection through port 443 on different Internet providers? MT3 had errors, but not so many.


Alas. "Since 12 at night" is not a statistic. For reasons unknown, the problems come in waves, then none, then several at once...
 
<br / translate="no"> Quark, have a conscience, don't post such logs on the forum =)))))


I thought - who cares (fiddler's tone from Kindzadz) :))


Regarding the reality of closing/opening - I have checks in all f-functions and errors appear, but they are FALSE errors. I checked the logs and order history, all positions were closed. The order just didn't have time to move in the history. I made a 1 second delay before checking - but that's not enough... When I asked, they didn't give me any answer.


Good point. But I've had cases where even an hour later the order hasn't gone anywhere, that is, sometimes they're not false.
I have a delay of 10 seconds too.
 
That's a good point. But I've had cases where even an hour later the order hasn't gone anywhere, i.e. sometimes they're not false. <br / translate="no"> I also have a delay of 10 seconds each.

All my mistakes, as it turned out, were in the code =) i.e. I did the wrong check after the orderclose.
After I corrected it - there are none. It's true that not much time has passed, we have to wait...
 
<br / translate="no"> all my errors appeared to be in the code =) i.e. I did the wrong check after orderclose.
After I corrected it - there are none. It's true that not much time has passed, we'll have to wait...


How does the corrected code look like?
 
What does the corrected code look like?

for orderclaus:
//---- check if the position has actually closed and if not, output the information and exit, returning -5 for ( int x = 0; x < 5; x ++ ) { Sleep(1000);
		if ( OrderSelect( Close_OrderTicket, SELECT_BY_TICKET ) ) { if ( OrderCloseTime() <= 0 ) { Processing_Error ( 0, "OrderClose" ); _Return_ ( 3, "Error", 0, "Position was not closed", "OrderClose(...)", "The position was not closed" ); return(-5); } else { break; } } Close_GetLastError = GetLastError(); _Print_ ( 3, "OrderSelect( " + Close_OrderTicket + ", SELECT_BY_TICKET )", "Error #" + Close_GetLastError + " ( " + ErrorDescription( Close_GetLastError ) + " )" ); }


for ordersand - just a 5x attempt to select an order with a second pause,
for modifiersand - comparing the old values with the current values