Please help... how to modify t/p after an open position

 
base on the code the position will keep on open if the price keep on going up. The problem is how should i modify the previous t/p open position to the latest t/p open position. Thanks in advance!
Files:
please.txt  2 kb
 

void modifyorder()
{

for( i=OrdersTotal(); i>=0; i--)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true && OrderSymbol()== Symbol() && OrderMagicNumber()!=MAGICMA)

{
OrderModify(OrderTicket(),0,0,0,0,Blue);
}

}

}

Reason: