# How do i code the same EA to run on different currency pairs without interference?

13

I want to trade the same EA on different currency pairs(charts) and it seems there is a conflict.

I loaded my EA on EUR/USD and it placed an order, however it didn't place an order on GBP/USD when the entry condition was meet.

Please how do i code the same EA to run independently of each other, so i can place different trades on different currency charts.

I use magic numbers, i guess i would have to assign each instance of a running EA a unique magic number by editing the properties.

if(OrdersTotal()==0)
{
{
if(PreviousCCI<=-100 && CurrentCCI>=-100)
{
int ticket1;
if(ticket1<0)
{
}
else
{

}
589

Topnotch:

if(OrdersTotal()==0)
{
{
if(PreviousCCI<=-100 && CurrentCCI>=-100)
{
int ticket1;
if(ticket1<0)
{
}
else
{

}

I cannot see an OrderSelect() call? However, it is clear that your EA will only handle one position at the same time, as your if-condition is based on number of open orders.

You probably wouldn't even need different magic numbers, as you can filter your OrderSelect() loop by symbol. Feel free to ask further questions, if this doesn't really help yet.

13

PomeGranate:

I cannot see an OrderSelect() call? However, it is clear that your EA will only handle one position at the same time, as your if-condition is based on number of open orders.

You probably wouldn't even need different magic numbers, as you can filter your OrderSelect() loop by symbol. Feel free to ask further questions, if this doesn't really help yet.

Thanks. i still need help. i further enhanced my code by add a global function as a filter please would this work?

{

int total=0;

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

{

if(MagicNumber ==OrderMagicNumber())

total++;

}

return(total);

}

{
{
if(PreviousCCI<=-100 && CurrentCCI>=-100)
{
int ticket1;
if(ticket1<0)
{
}
else
{

}
16071

1.  Play video Please edit your post. For large amounts of code, attach it.

2. ```  if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(MagicNumber ==OrderMagicNumber())
total++;```
This give you the total open/pending orders for the MN. It is incompatible with the EA running on other charts. Filter by pair. If the EA could be placed on the same pair but different timeframes, you must use a range of magic numbers.
330

Topnotch:
I want to trade the same EA on different currency pairs(charts) and it seems there is a conflict.

I loaded my EA on EUR/USD and it placed an order, however it didn't place an order on GBP/USD when the entry condition was meet.

Please how do i code the same EA to run independently of each other, so i can place different trades on different currency charts.

I use magic numbers, i guess i would have to assign each instance of a running EA a unique magic number by editing the properties.

if(OrdersTotal()==0)
{

}

You cannot use OrdersTotal() because that looks at orders across all pairs. Use something like this to filter specifically to Symbol().

```int OpenOrdersThisPair(string pair)
{
int total=0;

for(int b=OrdersTotal()-1; b>0; b--)
{
if(OrderSymbol()==pair) total++;     //can add more specific criteria if you want to trade across multiple timeframes on same pair by using magicnumbers.
}
return(total);
}```
13

DeanDeV:

You cannot use OrdersTotal() because that looks at orders across all pairs. Use something like this to filter specifically to Symbol().

Thank you, this is what i now actually use rather than OrdersTotal(). Good Enough?
```int totaltrades()

{

int total=0;

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

{

if(MagicNumber ==OrderMagicNumber())

total++;

}

return(total);

}