The formula
Position size = (Account × Risk%) ÷ (Stop distance in pips × pip value).
A worked example
£10,000 account, 1% risk = £100. Stop of 25 pips on EUR/USD at roughly £8 per pip per standard lot = £100 ÷ (25 × £8) = 0.5 lots.
Do it before you enter
Never open a trade and then work out what your stop should be so the loss feels bearable. Set the stop first, size the trade to match.