to all programming gurus out there,i'm facing a small problem with the for loops below, ok to explain briefly, the EA will before placing a pending buy order it will
1st chk for any current open BUY position if there is it will not place the pending buy
then if there is no open BUY position, it will continue to check for existing BUYSTOP order, if there is a BUYSTOP order found it will delete it and place a new BUYSTOP order.
i had written the code below but it seems it fails to get into the 1st for loop. can any1 lend a hand. thanx a million !
http://1.bp.blogspot.com/_NEedAj8WIe...0/s1600/EA.jpg
1st chk for any current open BUY position if there is it will not place the pending buy
then if there is no open BUY position, it will continue to check for existing BUYSTOP order, if there is a BUYSTOP order found it will delete it and place a new BUYSTOP order.
i had written the code below but it seems it fails to get into the 1st for loop. can any1 lend a hand. thanx a million !
http://1.bp.blogspot.com/_NEedAj8WIe...0/s1600/EA.jpg
Inserted Code
if (high2low > Buy1_2 && candle_close < candle_open) { pending_buy = var_high + 0.0001; // store the high +1 pips int k=OrdersTotal(); Print("k=",k); if(k==0) Order = SIGNAL_BUY; else for(int j=0;j<k;j++) { Print("INSIDE FOR LOOP1"); OrderSelect( j, SELECT_BY_POS ); Print("Ordertype=",OrderType()); if(OrderType() != OP_BUY) for(int l=0;l==k;l++) { Print("INSIDE FOR LOOP2"); OrderSelect( l, SELECT_BY_POS ); if(OrderType() == OP_BUYSTOP) {OrderDelete( OrderTicket(), DarkGoldenrod ); Order = SIGNAL_BUY;} else Order = SIGNAL_BUY; } } }