Need help in checking if statement

Back to topics list To post a new topic, please log in or register
akshay12489 2015.08.21 12:06

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 :(

WHRoeder 2015.08.21 13:34 #
  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
akshay12489 2015.08.21 15:55 #
Thanks for your help, its working fine now. :)
Back to topics list  

To add comments, please log in or register