Try This Function :
void SetAllTP(double tp,int direction)
{
//check for a clean tp
tp=NormalizeDouble(tp,Digits());
//check all orders
bool selected;
bool modified;
for(int x=0;x<OrdersTotal();x++)
{
//select trade
selected=OrderSelect(x,SELECT_BY_POS,MODE_TRADES);
if(selected)
{
//if trade is on this pair and of this magic number
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MN)
{
//and its direction matches the direction received upon function call
if(OrderType()==direction)
{
//attempts to modify
for(int a=0;a<9;a++)
{
modified=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),tp,0,clrOrange);
if(modified)
{
break;
}
Sleep(612);
}
//attempts to modify end here
}
//and its direction matches the direction received upon function call ends here
}
//if trade is on this pair and of this magic number ends here
}
//select trade ends here
}
//check all orders ends here
}