I am placing 2 pending orders simultaneous, a buy and sell at certain levels. Once the order is placed, now I want to delete one order as soon as the other order is triggered.
Here's what I have written for that. But it doesnt seem to be working. Please tell me what is wrong with this code.
Here's what I have written for that. But it doesnt seem to be working. Please tell me what is wrong with this code.
PHP Code
int order_type; int iTotal = OrdersTotal(); if(iTotal < 1) { int iTicketBuy = OrderSend(Symbol(),OP_BUYSTOP,iLots,UpEntry,3,iSL,iTP,"EURUSDBUY",iMN,iExpire,Green); int iTicketSell = OrderSend(Symbol(),OP_SELLSTOP,iLots,LowEntry,3,iSL1,iTP1,"EURUSDSELL",iMN1,iExpire,Red); if (iTicketBuy>0) { if(OrderSelect(iTicketBuy,SELECT_BY_TICKET,MODE_TRADES)) { Print("Buy Order Placed : ",OrderOpenPrice()); } else { Print("Error Placing Buy Order : ",GetLastError()); } } if (iTicketSell>0) { if(OrderSelect(iTicketSell,SELECT_BY_TICKET,MODE_TRADES)) { Print("Sell Order Placed : ",OrderOpenPrice()); } else { Print("Error Placing Sell Order : ",GetLastError()); } } } else if (iTotal > 0) { if(OrderSelect(iTicketBuy, SELECT_BY_TICKET,MODE_TRADES)) { order_type = OrderType(); if (order_type == OP_BUY) { OrderDelete(iTicketSell); } } else if(OrderSelect(iTicketSell, SELECT_BY_TICKET,MODE_TRADES)) { order_type = OrderType(); if (order_type == OP_SELL) { OrderDelete(iTicketBuy); } } }