if(use_sl_and_tp && total()>1)
{
double s_l, t_p;
for(i=0; i<OrdersTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || OrderType()>1) continue;
type=OrderType();
s_l=OrderStopLoss();
t_p=OrderTakeProfit();
}
for(i=OrdersTotal()-1; i>=0; i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || OrderType()>1) continue;
if(OrderType()==type)
{
if(OrderStopLoss()!=s_l || OrderTakeProfit()!=t_p)
{
OrderModify(OrderTicket(),OrderOpenPrice(),s_l,t_p,0,CLR_NONE);
}
}
}
}