More order limit at same price when use For loop

 

I have a code. I want order Buy Limit. But when used For loop find entry buy limit. Have more order at same price.

    

for(int i = 0; i < ArraySize(Dinh); i++)
{
if(CountLevel(Dinh[i])=0){
trade.BuyLimit(0.01,Dinh[i],NULL,DinhtoFVG[i],Dinh[i]+500*_Point);
}}

How to have only 1 order at a specific price?

I used conditional function to limit, but still not working

   int CountLevel(double price)
   {
      int count = 0;
      for(int i= OrdersTotal() - 1; i >= 0 ; i--)
        {
         long OrderType = OrderGetInteger(ORDER_TYPE);
         if(OrderSelect(OrderGetTicket(i)))
           {
            string _symbol = OrderGetString(ORDER_SYMBOL);
            if(_symbol == _Symbol )
            {
            if(price == OrderGetDouble(ORDER_PRICE_OPEN))
            count++;            
            }
            }
         }
      return count;    
     }
Files:
Capture.PNG  96 kb
 
Kid68:

I have a code. I want order Buy Limit. But when used For loop find entry buy limit. Have more order at same price.


How to have only 1 order at a specific price?

I used conditional function to limit, but still not working

Fix your IF condition 
= is an assignment. 
 == is a comparison