# Searching for opened orders my magic number - page 2

Moderator
10536

```int AreThereOrders ()  //Why use an int, the function is a true false question
{
if (OrdersTotal()<1)
{
return 1;
}
else if (OrdersTotal()>0)  //No need for the else as you have alreaddy returned if OT is less than 1
{

int i;

for (i=OrdersTotal()-1; i>=0; i--)
{
continue;
if( OrderMagicNumber()!= magic && OrderSymbol()!=Symbol()) //This means that if  any order is open that does not have
{                                                          //the magic number or chart symbol, a new order is opened
return 2;
}

}

}
return 0 ;
}```

more sensible, in my opinion

```bool AreThereOrders()
{
if(OrdersTotal()<1)
{
return (false);
}

int i;
for(i=OrdersTotal()-1; i>=0; i--)
{
continue;
if(OrderMagicNumber()==magic && OrderSymbol()==Symbol())
{
return (true);
}
}
return (false);
}```

``` if (AreThereOrders() == 1 || AreThereOrders() ==2)
{
}```

use

``` if (!AreThereOrders())
{
}```

more logical.

118

What i meant is that i want to open orders in 2 cases - if,  no order is open, and if there is already an open order, but it has to be from another EA, so that my new order will be the only order for the specified currency . My idea is to have only 1 order per EA / currency/, so that why i `ve written if the magic number doesn`t match it can open a new order/ because it will be from another EA/ and i will have only 1 per currency. But the problem is that it doesn`t open only 1 order for the currency. Maybe before i didnt explain it very well.
Moderator
10536

Stan4o1:
What i meant is that i want to open orders in 2 cases - if,  no order is open, and if there is already an open order, but it has to be from another EA, so that my new order will be the only order for the specified currency . My idea is to have only 1 order per EA / currency/, so that why i `ve written if the magic number doesn`t match it can open a new order/ because it will be from another EA/ and i will have only 1 per currency. But the problem is that it doesn`t open only 1 order for the currency. Maybe before i didnt explain it very well.

and that is precisely what

```      if(OrderMagicNumber()==magic && OrderSymbol()==Symbol())
{
return (true);
}```

achieves

118

Wow It worked thanks very very much :)))