it's simple, in theory at least.
you need an exit target and only exit if the trade is compromised technically or fundamentally, ie. dont exit for emotional reasons.
so
A] you must have an actual price target, have it firmly in mind.
B] use trailing stops if possible to lock in some profit
C] you must have confidence in your target; this only comes once you have tested and re-tested your strategy; knowing for example, that your target is reached say 70% of the time
if you have A], B] and C],
you will be more inclined to wait for your target and less inclined to exit early.