Error 146 ("Trade context busy") is due to Broker Server Side or MT4 Client Side?

 
Hello,

I am using an EA attached to 4 currency pairs in one MT4 client. I frequently encounter an error "Trade context busy." My question is, is this error due to my computer hardware resource issue (RAM/CPU), Metatrader 4 application-related issue, or Forex broker server-side issue?

If this is a Metatrader 4 client-side issue, and I open 4 MT4 applications on my computer and run 1 pair in each for the same trading account, will this issue be fixed?

Thank you.
 

https://book.mql4.com/en/trading/common

Only one execution thread is provided in the client terminal to perform trades. This means that the client terminal can simultaneously work only with one request. If there are several Expert Advisors or scripts trading in the client terminal and no program has passed a trade request to the client terminal, the trade requests of all other Expert Advisors and scripts will be rejected until the client terminal completes processing the current request, i.e., until the trade thread is free.
 

Read the entire page at this link

 
Vladislav Boyko #:
Only one execution thread is provided in the client terminal to perform trades. This means that the client terminal can simultaneously work only with one request. If there are several Expert Advisors or scripts trading in the client terminal and no program has passed a trade request to the client terminal, the trade requests of all other Expert Advisors and scripts will be rejected until the client terminal completes processing the current request, i.e., until the trade thread is free.


if I open Four MT4 applications on my computer and run 1 pair in each for the same trading account, will this issue be fixed?,. As this is not an error from Broker server

 
anuj71 #:

if I open Four MT4 applications on my computer and run 1 pair in each for the same trading account, will this issue be fixed?,. As this is not an error from Broker server

Try to do this using a demo account. But I think it is much easier to repeat the trade order after the trade flow is free.

 
If it is critical for you to avoid waiting for the trade flow to become free, then it is better to use MT5 asynchronous trading
 
Vladislav Boyko #:
If it is critical for you to avoid waiting for the trade flow to become free, then it is better to use MT5 asynchronous trading

MT5 Have multi-thread and tasking?

 
anuj71 #:

MT5 Have multi-thread and tasking?

short answer is hell -- yes.

 
anuj71 #:

MT5 Have multi-thread and tasking?

I would not call it multithreading because this term usually means something else.

https://www.mql5.com/en/docs/trading/ordersendasync

OrderSendAsync

The OrderSendAsync() function is used for conducting asynchronous trade operations without waiting for the trade server's response to a sent request. The function is designed for high-frequency trading, when under the terms of the trading algorithm it is unacceptable to waste time waiting for a response from the server.

Most likely, you should just wait for the trade flow to become free. Unless you are trading baskets of orders with dozens of trade orders being sent at the same time.

 
anuj71 #:


if I open Four MT4 applications on my computer and run 1 pair in each for the same trading account, will this issue be fixed?,. As this is not an error from Broker server

it is possibly due to all your eas, 1 on each instance of mt4 -- attempting to open a trade at the exact same time. It is not mt4 problem either, but rather your problem. If you can not put all eas on a single instance of mt4, then, I suggest that you code the ea for mt5, instead. As @Vladislav Boyko has hinted at: mt5 has more connections, those connections are generally faster, and both the server and client are capable of multiple orders at same time -- but still not guaranteed to avoid the problem, however. If your eas are making so many trades, in such small period of time, maybe you should have a unique trading account for each ea and pair -- if only to avoid the slippage that will inevitably occur doing it your current way.

 
Michael Charles Schefe #:
short answer is hell -- yes.

In one of the forum, i read MT5 have 8 Trade context and MT4 have only 1 Context but other part of the forum says MT4 have 8 context too. Any idea how many context does MT4 and MT5 have?

Vladislav Boyko #:
Most likely, you should just wait for the trade flow to become free. Unless you are trading baskets of orders with dozens of trade orders being sent at the same time.

EA is attached to multiple chart. So, yes many trade is getting send or modify at same time. Is that true MT5 have more Trade context compare to MT4?

Reason: