Need help in checking if statement

 

I have a certain condition in code where I define the BuyPrice


total = OrdersTotal();

if ( Bid >= BuyPrice1 && total <1)                                           // Buy Order 1
   OrderSend (Symbol(),OP_BUYLIMIT,Lots,BuyPrice1,0,0,0,NULL,0,clrNONE); 
    

 if (Bid >= BuyPrice2 && total<2);                                             // Buy order 2
   OrderSend (Symbol(),OP_BUYLIMIT,Lots,BuyPrice2,0,0,0,NULL,0,clrNONE);
   
Now my problem is that first if condition send only one buy limit order as required buy in second if condition it fires buy order on every tick. I cant seem to figure out what iss wrong :(
 
  1. if (Bid >= BuyPrice2 && total<2)                                          // Do nothing
    OrderSend (Symbol(),OP_BUYLIMIT,Lots,BuyPrice2,0,0,0,NULL,0,clrNONE);       // Buy order every tick
  2. Also note that in total<2, total has not changed.
  3. Check your return codes. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
 
Thanks for your help, its working fine now. :)
Reason: