Here is the scenario.
I place a buy stop order(Ticket1) and sell stop order(Ticket2)
Both the tickets have the stop loss and take profits filled in.
Now lets for example say the buy order(Ticket1) gets filled in.
I want to delete the other pending order(Ticket2) only if my TP level is hit.
Here is my piece of code.
My current Problem - The pending order is getting deleted the moment the active trade either hits the SL or TP. However, it must only get delete when the TP is hit.
Please help.
I place a buy stop order(Ticket1) and sell stop order(Ticket2)
Both the tickets have the stop loss and take profits filled in.
Now lets for example say the buy order(Ticket1) gets filled in.
I want to delete the other pending order(Ticket2) only if my TP level is hit.
Here is my piece of code.
Inserted Code
if (OrdersTotal() == 1 ) {//a if(OrderSelect(Ticket1, SELECT_BY_TICKET,MODE_TRADES)==true) {//b order_type = OrderType(); if (order_type == OP_BUY && OrderProfit() > 0 ) { OrderDelete(Ticket2); } }//b- }//a-
My current Problem - The pending order is getting deleted the moment the active trade either hits the SL or TP. However, it must only get delete when the TP is hit.
Please help.