Trade muliple currency Pairs

 

Most of the sample EA that come with metatrader have some code in it that do not allow more than one order at a time. What code would I use to allow more than one order if it is a different currency pair. For example if usdcad has an open position I do not want any more open. However I do want euros to trade if I signal is generated.

Thanks in advance

Randy

 
rbowles:
Most of the sample EA that come with metatrader have some code in it that do not allow more than one order at a time. What code would I use to allow more than one order if it is a different currency pair. For example if usdcad has an open position I do not want any more open. However I do want euros to trade if I signal is generated.

Thanks in advance

Randy

Most EAs are trading like this. And most EA are having magic number option which is doing it. And there is the other code which is protecting trading many EAs in one metatrader but I don't remember.

Check EAs (there are a lot on this forum), select one with Magic number option (in settings) and do the same with yours.

 
newdigital:
Most EAs are trading like this. And most EA are having magic number option which is doing it. And there is the other code which is protecting trading many EAs in one metatrader but I don't remember. Check EAs (there are a lot on this forum), select one with Magic number option (in settings) and do the same with yours.

I did find some with the magicnumber. Can somebody give me a brief description of what that is and how it functions. Once I have that I think I can work with it.

Thanks,

Randy

 
rbowles:
I did find some with the magicnumber. Can somebody give me a brief description of what that is and how it functions. Once I have that I think I can work with it.

Thanks,

Randy

My explanation is not good as I am not a coder.

But for example:

//Sell

if (Order == SIGNAL_SELL ....

if(Total < 1)

.....

Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);[/CODE]

So every ticket it having magic number (some number let's say). Means that all the orders are opened with this number.

And then EA is trying to find the orders with the same numbers to modify, close with sl or with tp.

[CODE]bool ExistPositions() {

for (int i=0; i<OrdersTotal(); i++) {

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {

if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {

return(True);

I could not find EA without magic number in my computer. Even very old EAs without magic numbers as the settings are having it inside the code:

{

OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-sl*Point,Ask+tp*Point,"qq-buy60",11603575,0,Blue);

}

 

I think I understand it now. I am a programmer and I just needed some time to digest it. I also found this link that might help others. http://www.metatrader.info/node/115

 
rbowles:
I think I understand it now. I am a programmer and I just needed some time to digest it. I also found this link that might help others. http://www.metatrader.info/node/115

I use a similar function in which I count the # of trades from within the expert and write it to a global variable. Then you simply have to have the EA's running on different charts check that global variable for the # of open trades. Easy as pie

Reason: