ticket1 = OrderSend( Symbol(),OP_BUYSTOP,LotSize,t1, Slippage,sl1,tp1,Order_comment,MagicNumber,0,clrGreen);
ticket2 = OrderSend( Symbol(),OP_SELLSTOP,LotSize,t2, Slippage, sl2,tp2,Order_comment,MagicNumber,0,clrRed);
}
for(int j=0; j<OrdersTotal(); j++)
{
//---if opened order is "Buy", close another pending order "Sellstop" and use trailing stop for opened "Buy" order
if (OrderSelect(ticket1,SELECT_BY_TICKET)==true)
if(OrderType()<=OP_BUY && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
// delete pending order
if (OrderDelete(ticket2)==true)
Print("Deleting SELL_STOP"," Ordertype:",OrderType());
return(1);
}
//---if opened order is "Sell", close another pending order "Buystop" and use trailing stop for opened "Sell" order
if (OrderSelect(ticket2,SELECT_BY_TICKET)==true)
if(OrderType()<=OP_SELL&& // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
// delete pending order
if (OrderDelete(ticket1)==true)
Print("Deleting BUY_STOP"," Ordertype:",OrderType());
return(1);
}