TradeDispatcher: all trade context is busy

 
How can I prevent this error from occuring?

"TradeDispatcher: all trade context is busy"
 
see this thread also....."TrADE"

I'd like to know if MT is serious about being a trading platform...right now I'm not half a impressed as I used to be...
 
wow, what is going on here?
 
Hi,

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

 
Hi,

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).
 
Hi Alexandr,

I was under the impression that this returned the setting reflected the property on the Common tab when attaching an EA to a chart. Similar to IsLibrariesAllowed and IsDllsAllowed. Can someone please confirm what this function actually does please?

Pedro
 
Hello pedfx,
That was my understanding also.

Alexandr,
The dictionary says,
Returns true if trade is allowed for the expert, otherwise returns false.
I think that this is quite unacceptably vague.

You also said in another post about this topic:
So this error message indicates that some trade operation was in progress when you try to do another one.

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?
 
IsTradeAllowed function was expanded. It check not only for "allow trade" flag in the expert properties but also for freeness of the trade thread that is only one for the all expert trades. There is not allowed simultaneous trades from several EA ie a few experts cannot processed trade operations at the same time
 
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

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
Reason: