I need help in this regard

 
int CheckBuyOrdersinLoss()
  {
   int op;
     {
     for(i=0; i<OrdersTotal(); i++)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
            if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicID) //
               if(OrderType()==OP_BUY )
                 {
                  if (OrderProfit() < 0) 
                     {
                     op++;
                     }
                 } 
        }  
     }
return(op);     
  }   
when i call this function, the ea stops immediately, i dont know what is wrong, i want to calculate the number of open trades running in loss
 
  1. op not initialized to zero.
  2. Your problem is elsewhere.
 
I found out the problem, thank you
 
Vijay Akash T P #: I found out the problem, thank you

Don't do that. Someone searching might find this thread and still be clueless. What was the problem? What solved what?

How To Ask Questions The Smart Way. (2004)
     When You Ask.
          Follow up with a brief note on the solution.

 
It is declaration of op to zero, solved the problem