Orders Accounting Opinions

 

Hello everyone,


I was looking for advice on orders accounting coding. I have coded 3 EA's that I am using, and have not tried to run them at the same time, but on separate MT4 terminals. I want to run them on the same terminal but am fearful my O.A. code is outdated.


Any code anyone use to run multiple, I am having difficulties and working on it currently, using the arrays.


I know its sounds confusing,


But grateful for any support.


Warmest regards,


ZRC

 
ZacharyRC:

Hello everyone,

I was looking for advice on orders accounting coding. I have coded 3 EA's that I am using, and have not tried to run them at the same time, but on separate MT4 terminals. I want to run them on the same terminal but am fearful my O.A. code is outdated.

Any code anyone use to run multiple, I am having difficulties and working on it currently, using the arrays.

I know its sounds confusing, 

Use OrderSymbol() and/or OrderMagicNumber() to determine which orders belong to which EA.  If you run Build 482 you shouldn't have problems with trade context busy any more,  but if you are worried you might you can investigate the use of a Mutex,  there is code on the Forum and also an article about it . . .   just search and you will find it.
 
RaptorUK:
Use OrderSymbol() and/or OrderMagicNumber() to determine which orders belong to which EA.  If you run Build 482 you shouldn't have problems with trade context busy any more,  but if you are worried you might you can investigate the use of a Mutex,  there is code on the Forum and also an article about it . . .   just search and you will find it.


Your the man Raptor, thanks!
 

I created this little piece of code and its working fine. (for future reference)

Thanks Raptor.


 bool EAtrade=false;
 int x;
 for(x=0; x<OrdersTotal(); x++)
 {
  OrderSelect(x,SELECT_BY_POS,MODE_TRADES);
  if(OrderSymbol()== Symbol()&&OrderMagicNumber()==MagicNumber)
  {
   EAtrade=true;
  }
  }
  
 
ZacharyRC:

I created this little piece of code and its working fine. (for future reference)

Thanks Raptor.

You are welcome,  it's good to see someone having a go for themselves . . .  ;-)  one suggestion,  get into the habit of checking that your functions have worked by checking their return values,  so . . .

 bool EAtrade = false;
 int x;
 for(x = 0; x < OrdersTotal(); x++)
    {
    if( OrderSelect(x, SELECT_BY_POS, MODE_TRADES) )   // did the OrderSelect work ? ?
       if( OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber )
          {
          EAtrade = true;
          }
    }

 More info here:  What are Function return values ? How do I use them ?

 
RaptorUK:

You are welcome,  it's good to see someone having a go for themselves . . .  ;-)  one suggestion,  get into the habit of checking that your functions have worked by checking their return values,  so . . .

 More info here:  What are Function return values ? How do I use them ?

 


Thank you Raptor,



I know, I forgot to do that again, will do and thanks for the tips.

Reason: