Stop loss
A stop loss is an order that automatically closes your position at a loss level set in advance. It caps your maximum risk on the trade.
You place the stop loss when you open the trade, where your idea is proven wrong: below support or a recent low for a buy, above resistance for a sell. Only then do you calculate your position size so that the stop equals your chosen risk, for example 1% of the account.
The golden rule: never widen it because price is getting close. You can tighten it or move it to break-even, never push it further away.
A stop does not guarantee the price: in a gap or around news it can be filled further away. It is still your best protection against the big loss that wrecks an account.