Too many EA's?

 

Hello everyone! I hope someone can help share some information for me here...I am running 5 EA's at once(I think that is the max you can run) and last night had this issue: both usdjpy and audusd gave me trade signals at the same time. However, one of my orders did not fill and I found out the "trade context was busy". I am going to post my order placing code below to see if there is any possible way around this problem. Has anyone had this issue? Is there a way (by changing my code perhaps) to help try and ensure this doesn't happen again? any help would be greatly appreciated! Thanks forum......


if(GlobalVariableCheck("usdchfStop")==false)//allows 4hr trades to be placed
{
if(MA1 > MA2 && H1 > H2)
{
if (L1 < L2 && c1 > O1 && GlobalVariableCheck("usdchfStop")==false)
{
//LONG USDCHF
OrderSend(C5,OP_BUY,lot,MarketInfo(C5,MODE_ASK),3,Ask-150*Point,Ask+5*Point,NULL,MagicNumber9,0,Green);
if (ticket9<0){verifyorder(C5,MagicNumber9,"LONG");}Sleep(5000);

OrderSend(C5,OP_SELLSTOP,lot2,Ask-150*Point,3,Ask-1*Point,Ask-170*Point,NULL,MagicNumber10,0,Green);
if (ticket10<0){verifyorder(C5,MagicNumber10,"LONG");}Sleep(5000);

GlobalVariableSet("usdchfStop",1);//allows only two orders to be put on!

}
}


In the failed trade example, the stop order was placed yet the original buy/sell did not get placed. Any ideas on how to beat this trade context issue? Thanks!! Dan

 
forexman05:

I found out the "trade context was busy". [...] Has anyone had this issue? Is there a way (by changing my code perhaps) to help try and ensure this doesn't happen again?

It's a well-known issue, and the the standard solution is as described in 'Error 146 ("Trade context busy") and How to Deal with It' - sections 5 and 6 of that article.


I am running 5 EA's at once(I think that is the max you can run)

I'm not aware of 5 being a maximum number of simultaneous EAs. I'm currently looking at a dashboard showing 6 EAs running on a single live MT4 instance, and I'm sure I've exceeded that number in testing in the past.

 

FM

First you need to retry your OrderSend on failure - and any OrderClose of course

An example is here 'sub-pip pricing/pipettes'

If that isnt enough, use more copies of MT to spread the load and get more 'trade contexts' available

Good Luck

-BB-

Reason: