CountTrades returns 0 if exists trade

 

Hi,

how can I skip trade int= 0 if not exists.


Also problem is if I have more different symbols: EURUSD, GBPUSD 

EURUSD: count = 2 GBPUSD: count = 1

int myCount()
  {
   int counts=0;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol())
           {
          //  if(OrderType()<=1)
               counts++;
             //  break;
           }
        }
     }
   return(counts);
  }
if (myCount()==0)
  {
    Alert("ok");
  }


if exists trade in MT still returns alert("ok")?

So the question is how can I return only count if exists in order?

 
chris.dotan: if exists trade in MT still returns alert("ok")?

Wrong. Your code only prints OK if no trade currently exists on the chart's symbol.