problem a lot of order

 

I build an Expert ,but it open a lot of orders at the same time. How can I make it to open just one order.

please.

    void OnTick()
      {


     int total=OrdersTotal();

      for(int pos=0;pos<total;pos++)
     
      if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES))
      OrderProfit();
      int ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,0,0,"op buy/1",123,0,clrBlue);
      double a=OrderProfit();
      Comment("profit order select",a);
      }




 

Haven't you posted this code already?

Write your code to check for an open order and only open a new order if there are none. 

Reason: