How to limit no of Buy Orders

 

Hi I want to write a EA that will place buy order at fix price interval like this


for (i = 0; i < 5; i++)
                {
                BuyPrice1 = BuyPrice + DPR*(i)/n;
                
                                if( Close[0] >= BuyPrice1)                                   // Buy Order 1
                
             ticket = OrderSend (Symbol(),OP_BUYLIMIT,Lots,BuyPrice1,0,0,0,NULL,0,clrNONE); 
                
 }


Where DPR, n is manual input, now lets say I want to buy USDJPY at 101 and DPR/n is 0.4 so it will place an order at 101.40 and so on. My problem is that keep placing order at every tick how do I stop it too the once per price increment ?

 
akshay12489: My problem is that keep placing order at every tick how do I stop it too the once per price increment ?
Where do you check if you already have placed the orders?
Reason: