Trailing price orders selling at a loss

Trying to improve my trailing price order management techniques. everything is going well except there are times when the program sells the trailing price order at a loss. is there any way to prevent this? Is there a way for the program to just hold an order till profit is made like a limit order? if I could program a stop loss that sells after maybe a 5% drop id be fine, but it seems to just sell the order for like no reason at all. Any tips would help a lot.