If many trades are open at the same time, the easiest way is a for(open_trades) loop that identifies your pending trade and closes it or changes its entry price.