TradeDispatcher: all trade context is busy
I think this is a big concern as not handling this problem can cost $$$. I have had a look at the error codes in the dictionary and these are ones I think may need to be handled to get arround this problem
ERR_SERVER_BUSY
ERR_TOO_FREQUENT_REQUESTS
ERR_BROKER_BUSY
ERR_ORDER_LOCKED
ERR_TOO_MANY_REQUESTS
Maybe having some code like.
bool b = true;
while (b)
{
int iStatus = OrderSelect(...); // This could be a OrderSelect, Modify, Send, Delete etc
b = CheckBusy(iStatus) //Return true for server busy codes
Sleep(10000); //wait 10 seconds before retrying
}
RefreshRates();
.......
bool CheckBusy(int i)
{
switch( i )
{
case ERR_SERVER_BUSY:
case ERR_TOO_FREQUENT_REQUESTS:
case ERR_BROKER_BUSY:
case ERR_ORDER_LOCKED:
case ERR_TOO_MANY_REQUESTS:
return (true);
}
return (false);
}
This may or may not work but may be worth testing on demo. Slawa could you please confirm the correct error codes that would need to be checked for in order for this type of action. Also may be worth adding some sort of counter so that you don't end up with and endless loop and maybe even worth sending an email on the first loop that picks up the error that way you are aware that a problem or trade collition exits.
Pedro
I think this is a big concern as not handling this problem can cost $$$. I have had a look at the error codes in the dictionary and these are ones I think may need to be handled to get arround this problem
You should use IsTradeAllowed( ) function (see "Common functions" topic in MetaEditor navigator).
That was my understanding also.
Alexandr,
The dictionary says,
You also said in another post about this topic:
Would IsTradeAllowed() cause the EA to pause and wait for the other EA to finish its trade operation first, and then allow it to continue as normal?
ERR_SERVER_BUSY
ERR_TOO_FREQUENT_REQUESTS
ERR_BROKER_BUSY
ERR_ORDER_LOCKED
ERR_TOO_MANY_REQUESTS
i think that enumerated errors definitions are self documented
ERR_SERVER_BUSY - server is busy. ask your broker what is happened
ERR_TOO_FREQUENT_REQUESTS - you cannot send requests every tick without pause
ERR_BROKER_BUSY - your broker processes another request from another client
ERR_ORDER_LOCKED - order that you've send is accepted and cannot be cancelled
ERR_TOO_MANY_REQUESTS - queue of your requests is full
"TradeDispatcher: all trade context is busy"