The one number
Decide the most you are prepared to lose on this trade if it goes wrong. In money, not percentage, not pips. Many traders use one or two percent of the account; the exact figure matters less than deciding it before the trade rather than after.
Where the stop goes
Place the stop where the trade idea is wrong, not where the loss feels acceptable. If the idea is that a level holds, the stop goes beyond the level. The distance from entry to stop, in pips or points, is your risk per unit.
The arithmetic
Position size = money you are prepared to lose ÷ (distance to stop × value per pip per lot). For EURUSD, one standard lot moves roughly $10 per pip. Prepared to lose $200 with a 40-pip stop: $200 ÷ (40 × $10) = 0.5 lots. That is the whole calculation.
What this does to leverage
Notice that leverage never entered the calculation. The position size came from the risk you chose and the stop you placed. If the resulting position needs more margin than you have, the trade is too large for the account, whatever leverage is available.
The habit that follows
Write the size and the reason down before you click. Review weekly, not hourly. Over a few months the pattern of sizes tells you more about your trading than any single result.

