I think you can put your trailing order in the for d in rtop loop.
Try something like:
self.order_target_percent(d, target=self.perctarget, transmit=False) self.sell(d, size=1, exectype=bt.Order.StopTrail, trailpercent=0.02, transmit=True)
The transmit False will hold the first order until the second is ready to submit. Please verify this code I have not checked it.