Examples: Error 146 ("Trade context busy") and How to Deal with It - page 2

 
Hmmm.. Can this error take place, even if it is the SAME EA running on different symbols? I mean, will it trip all over itself?
 
Thanks a lot worked for me, was looking exactly for the same.
 

Hi.

I'm using IsTradeAllowed () in a while loop (while (IsTradeAllowed () == false)) but only makes three attempts, after exit the loop. I would like not to go out of the loop until the order is placed. Can anyone help? 

Thanks. 

 
Jusyer:

Hi.

I'm using IsTradeAllowed () in a while loop (while (IsTradeAllowed () == false)) but only makes three attempts, after exit the loop. I would like not to go out of the loop until the order is placed. Can anyone help? 

Thanks. 

There is no need to do what you ask, if you read the article and follow the simple instructions.

Always check the result from OrderSend, OrderModify etc...  Use the result to determine if the placement was a success or not, and exit the loop according to that.
Just refrain from entering into endless-uncontrolled loops. 

 

Hey,

Iam try ing to use the 2 functions. But I don't get it to work

This is my test:

TradeIsNotBusy();

Print("Trade is Busy: " + TradeIsBusy());

TradeIsNotBusy(); // Entleeren den Trade-Context 

The Print function returns: 1

But the Global Variable table returns: 0


Do I do something wrong?

 
Florian Riedrich:

Hey,

Iam try ing to use the 2 functions. But I don't get it to work

This is my test:

The Print function returns: 1

But the Global Variable table returns: 0


Do I do something wrong?

TradeIsNotBusy();                                     // sets GV to 0

Print("Trade is Busy: " + TradeIsBusy());             // sets GV to 1, prints 1

TradeIsNotBusy(); // Entleeren den Trade-Context      // sets GV to 0 

Here is explanation.


But you don't need to use these functions. There are 8 trade contexts in MT4 several years already.

 

Hey Andrey,

thanks for reply. So you mean using 

IsConnected() && IsTradeAllowed() && !IsTradeContextBusy()

is enough?

What are the "8" contexts?

 
Florian Riedrich:

Hey Andrey,

thanks for reply. So you mean using 

is enough?

What are the "8" contexts?

Terminal have 8 trade contexts now, so it can send as much as 8 trade requests simulateously.

If you use less then 8 EAs at the same time, you could even not to check IsTradeContextBusy(). Otherwise, just check it and have a little sleep in case it returns false ;)

 
Andrey Khatimlianskii:

Terminal have 8 trade contexts now, so it can send as much as 8 trade requests simulateously.

If you use less then 8 EAs at the same time, you could even not to check IsTradeContextBusy(). Otherwise, just check it and have a little sleep in case it returns false ;)

Wow, good to know. I've been fiddling with the incorporation of whrea_v1.2's GetTradeContext()/RelTradeContext() functions into my EA for several hours... :)
Reason: