Download MetaTrader 5

Need help in checking if statement

To add comments, please log in or register
Why to sell products in MetaTrader AppStore? Find that out from the article!
Akshay
48
Akshay 2015.08.21 10: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 :(
whroeder1
14544
whroeder1 2015.08.21 11: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
Akshay
48
Akshay 2015.08.21 13:55  
Thanks for your help, its working fine now. :)
To add comments, please log in or register