This is likely the most disputed practice among traders, As a beginner you should get in the habit of taking profits AS SOON AS THE MARKET MAKES THEM AVAILABLE TO YOU! As soon as your trade is up 20-30 pips you should move your stop loss to break even, that way you are no longer exposed to risk of any type and you have a free trade on your hands, now if the price keeps moving in your directions, move your stop loss level accordingly. Of course if you are “scalping” this would be a much narrower window, ie move your stop to break even at 5 pips.
Also try to trade with a broker that allows custom lot sizes, that way you always have the option to take off a portion of your trades, allowing you to take off some profits, while letting the remaining portion of your position accumulate more value.
Dont wait too long or the market could very well take it all back and then some, often much quicker than it took you to achieve those gains.