Is a client account limited to the single trading operation at the same time?

 

According to the official MQL4 documentation for trading functions (https://docs.mql4.com/trading) a MetaTrader 4 Client Terminal has only one thread for trading operations which means only one trading operation can be executed at the same time - others fail with the error 146 (ERR_TRADE_CONTEXT_BUSY) if they are sent simultaneously.

The question is if it is possible to send two trading operations (for the same account) to the same server at the very same time if they are sent from two different terminals? Are the trading operations queued on the server? Or only that one which comes first is queued when the other one is refused with the error 146 (ERR_TRADE_CONTEXT_BUSY)?

Is MetaTrader 4 Server responsible for queuing trading operations from clients? Or it is a subject of so-called bridge software (which deals directly with the market?)

In other words, if the client account is limited to the single trading operation at the same time on the server side, or it is the limitation of the client terminal?

 
Why don't you try it from different IP. However the result may different from one broker to another, or you may get error 137 (Broker is busy) :(
 
Just use a mutex to send one order at a time.
 
evgenypavlyuk:

The question is if it is possible to send two trading operations (for the same account) to the same server at the very same time if they are sent from two different terminals? Are the trading operations queued on the server? Or only that one which comes first is queued when the other one is refused with the error 146 (ERR_TRADE_CONTEXT_BUSY)?

My broker explicitly says that for any particular server, orders get put in a queue. All orders from all customers. The separation between orders is probably sub-millisecond but it is still a queue. It's only a problem during news events when the servers get over-loaded and backed-up with orders.
 
WHRoeder:
Just use a mutex to send one order at a time.

I am not talking about synchronization facilities. It makes sense only if expert advisors on the same terminal use the same way to access the shared resource (trade context.) It is senseless if client runs experts provided by different vendors on the same terminal.

The MQL4 function IsTradeAllowed is unhelpful, because two expert advisors may call it at the very same time, both get true, and try to request a trading operation, but the slowest one fails.

dabbler:
My broker explicitly says that for any particular server, orders get put in a queue. All orders from all customers. The separation between orders is probably sub-millisecond but it is still a queue. It's only a problem during news events when the servers get over-loaded and backed-up with orders.

I would like to know if queuing of trade operations is the subject of MetaTrader 4 Server itself, or a third-party software (bridge, dealer plug-in, whatever) is responsible for queuing.

onewithzachy:
Why don't you try it from different IP. However the result may different from one broker to another, or you may get error 137 (Broker is busy) :(
If the server does not allow multiple trade operations from the same client at the same time, it does not matter what an IP is used. Client may be identified by account number on the server side.
 

If MetaTrader 4 Server is initially responsible for queuing of trade operations, and it natively supports multiple trade operations from the same client (of course broker can apply any extra logic later), it is possible to use two different terminals for the same account to send trading operations at the very same time (if such a situation takes place.) That is the question.

 

evgenypavlyuk:

If the server does not allow multiple trade operations from the same client at the same time, it does not matter what an IP is used. Client may be identified by account number on the server side.

If MetaTrader 4 Server is initially responsible for queuing of trade operations, and it natively supports multiple trade operations from the same client (of course broker can apply any extra logic later), it is possible to use two different terminals for the same account to send trading operations at the very same time (if such a situation takes place.) That is the question.

I open two MT and same accounts, and it's OK.

I know what you mean - What would happen if orders from 2 MT (or more) of the same accounts reach broker server at the same time ?.

We'll never know, plenty thing happen on the way to heaven ... i mean ... server. I think it's more to broker discretion then :(

 
onewithzachy:

I open two MT and same accounts, and it's OK.

I know what you mean - What would happen if orders from 2 MT (or more) of the same accounts reach broker server at the same time ?.

We'll never know, plenty thing happen on the way to heaven ... i mean ... server. I think it's more to broker discretion then :(

Yes, that's what I mean.

Thanks all for the answers. I'll try to run multiple terminals for the same account.

 
evgenypavlyuk:

Yes, that's what I mean.

Thanks all for the answers. I'll try to run multiple terminals for the same account.

When I said 'broker discretion', I was thinking more like re-quotes, reject, or something like that. I just remember that several years ago there was this guy complaining that his EA closed order at the same broker time but his order was closed at different price. The broker replied (or argued) that the order close was accepted in queue, and was executed at different second time and at slippage sent by him.

You see, in MT order history, the closed times are in minutes - not in seconds - and there is slippage in order close. And I don't think there are any orders that is executed more than a minute. They are always executed in milisecond.

:(

Reason: