ERR_TOO_MANY_REQUESTS (Error: 141). Too many requests per what?

 

Too many requests per what?

Does anyone know anything more specific about error 141 than the rather tautological information here: https://docs.mql4.com/trading/errors ?

ERR_TOO_MANY_REQUESTS141Too many requests. The frequency of requesting must be reduced, the program logic must be changed.


I am getting a large number of 141 errors (specifically 141 - never 142, 143 or 144).

In order to overcome trade context busy errors (and to limit the impact of an MT4 terminal with multiple EAs randomly losing connection) I have started running multiple terminals (>5) connected to the same account - each running a separate EA (with separate magic numbers).

Sometimes many EAs happen to open at the start of the same candlestick. When about 5 or more EAs send simultaneous open orders, I get error 141.

Obviously the error does not mean "too many requests per MT4 terminal" because there is only one request per terminal going through, and I'm not getting trade context errors.

Does anyone know whether this error might be caused by a bottleneck in communication from my pc to the broker ("too many requests per internet connection"),

or whether it might be caused by the broker placing a limit on the number of simultaneous orders per account ? ("Too many requests per account"). Though I can't find anywhere in the T&Cs that my broker specifies such.

The error 141 does not occur when an EA sends open requests on it's own. (There is only one request sent at a time per EA - and the code waits for an error from the first attempt before sending another request. The max number of requests is limited to 10 per EA per 5 mins anyway).

I have sufficient error handling to overcome the error when it occurs -- but I would like to try and prevent the error ever occurring, or at least find out exactly why it occurs for my own peace of mind. Does anyone know where the problem is most likely to be? Thanks.

 

What about Refreshrates() ? you shouldn't handle errors due to Trade Context Busy . . you should avoid them with a Mutex.

https://www.mql5.com/en/forum/139633/page2#636683

 

I don't think RefreshRates() is the problem. I refresh before every order send, and correctly refresh even in the cycles. There are no 141 errors when EAs work on their own, even when they overcome multiple errors.

Yeah, I already (successfully) wrote my own semaphore to avoid a busy trade context - but I ditched it straight after I wrote it, for 2 reasons:

1) Only one trade can occupy the mutex at any one time - so if a trade timeout error occurs (which lasts for an average of 20sec on my broker, and there can frequently be up to 3-6 in a row) then ALL the other trades have to wait, and there is no work around. If multiple terminals are used to access the same account, then each EA seems to work independently of the timeout errors in the others (as far as I have been able to determine). Obviously trades still have to be separated by magic numbers, which I was already doing with the semaphore.

2) Some of my terminals seem to randomly disconnect for a short while. I would rather have just one EA disconnect at a time, than risk x number of EAs all disconnecting at the same time.

Therefore I am now using one EA per terminal, and many terminals per account - so no semaphore for trade context is required and as a result my trades seem to get placed much faster (especially the trades which would have been at the end of the queue).

But either way, I'm pretty sure there are no "trade context" errors occurring. Am I right that the 141 error occurs outside the trade context for any given terminal?

 

Thanks, you are right: it doesn't make sense to simply handle the error after it occurs, but rather to try and prevent it in the first place. I suppose I could use a mutex system between terminals, but that would simply fall victim to the same trade timeout errors mentioned in 1) above.

If the bottleneck is occurring per internet connection then perhaps I could try multiple connections, or maybe routing through multiple ip addresses. However, if the problem is per account then that would obviously be a waste of time. Opening more accounts is not possible.

 
clerin6:

Thanks, you are right: it doesn't make sense to simply handle the error after it occurs, but rather to try and prevent it in the first place. I suppose I could use a mutex system between terminals, but that would simply fall victim to the same trade timeout errors mentioned in 1) above.

If the bottleneck is occurring per internet connection then perhaps I could try multiple connections, or maybe routing through multiple ip addresses. However, if the problem is per account then that would obviously be a waste of time. Opening more accounts is not possible.




Well;) I get this sometimes even with only one EA running on and FXCM Active Trader account.  I suspect this is basically the same as Trade Context Busy.  Maybe it's a race condition, becomes busy as you are sending the request. IE it's the broker that is busy in general not just dealing with your specific requests.
 
Yes sometime the broker is busy and can not accept your trading request
 
  1. 141 has nothing to do with refresh rates - you'd get a different error, like 130
  2. 141 has nothing to do with context busy - you'd get 146
  3. 141 has nothing to do with server busy - you'd get 137
  4. 141 occurs when you send the same command (orderSend(invalid) orderModify(..)) over and over in a short period of time. Look for the error message BEFORE the 141. Check ALL your return codes and log them. What are Function return values ? How do I use them ? - MQL4 forum
Reason: