When you are comfortable with your profit or better still, when you have decided from get go the target price for your exit from a particular trade, that when you should sell. However, there are market conditions that could make you sell earlier or later than planned.
According to my experience, on any financial market, we can not create fixed strategy and plan for investment.
Anytime, our plan can be change by something, example the FUD, FOMO by the whale or bad news from the government, etc.
Therefore, I am always ready with any worse situation I can imagine, because when I am already with these situations, I can have solution and enough calm to keep my funds.