# Function is getting some operator is needed

Can you see what is wrong here? I get some operator is needed when calling this function. I want to scan orders on other currency pairs on other charts and see what type the other orders are, and set it to a number of 1 if it is active. So I call it two times one for buy and one for sell. But it is not working

```  int TypeByCurrency(string Name, int typ)
{
int Type=0;
int nr=0;

for (int ic=0; ic<OrdersTotal(); ic++)
{
if ( OrderSelect(ic,SELECT_BY_POS,MODE_TRADES) && OrderSymbol() == Name && (OrderMagicNumber() == MagicNr || OrderMagicNumber() == 0))
{
Type = OrderType();
nr=ic;
}
}
if(nr>0 && Type==0 && typ==0)
{
Type=1;
}
else if(nr>0 && Type==1 && typ==1)
{
Type=1;
}
else
{
Type=0;
}

return(Type);
}```

Cleasfifthy:

Can you see what is wrong here? I get some operator is needed when calling this function. I want to scan orders on other currency pairs on other charts and see what type the other orders are, and set it to a number of 1 if it is active. So I call it two times one for buy and one for sell. But it is not working

Try to get error() when coding, it will save you a lot of time.

I suggest to change the way you get the type of order. I use this type of code for getting a position. Do the same with orders. If you'll get more than one order use count++ to get it's number.

```double positionSell=0;
for(int i=PositionsTotal()-1; i>=0; i--)
if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)
{

if(m_position.PositionType()==POSITION_TYPE_SELL)
positionSell=1;
}```
Reason: