Forex Position Size Calculator
Your risk budget and your stop distance, turned into units and lots — with the spread, the commission and your broker's lot step taken out first, so the number you trade is the number that actually fits the loss you allowed.
At a glance
- Size = risk budget ÷ stop distance, in money per unit for the pair you are trading. Everything else on this page is that division with the costs taken out.
- The lot step changes the answer: on the worked example, a 0.01 step gives 25,000 units while a 0.10 step gives 20,000 — and the smaller step leaves only 2.63 of the budget unused against 15.91.
- Ignoring costs oversizes the trade. The same example without spread and commission says 58,000 units, which loses 85.23 at the stop instead of the 74.30 you budgeted.
- Halving the stop distance doubles the size for the same risk: 20 pips gives 50,000 units, 40 pips gives 25,000.
Contract specification and leverage (editable)
How the size is worked out
Four numbers decide everything on this page: the money you are willing to lose, the distance to your stop, the cost of getting in, and the increments your broker accepts. Nothing else influences the result, including leverage — leverage changes the margin you post, not the amount you risk.
Of the four, the stop distance is the one most often rounded off to a tidy number. It should be a price that exists on your chart before you type it here. TrendSpider is a charting platform worth looking at for that step — it is one way to get an actual level rather than a number that felt right.
- The spread sits inside the stop distance because you pay it at entry, before the trade can move anywhere.
- The commission comes off the budget because money spent on fees can no longer be risked on the trade.
- Rounding always goes down. Rounding to nearest would quietly increase risk, and rounding up increases it openly.
- The worst case is recomputed from the rounded size, so you see the real loss rather than assuming it still fits.
A raw result that lands within one billionth of a whole increment is treated as that increment, so floating-point noise in JavaScript cannot cost you a tradable step. Everything below the number of increments that fit is simply discarded, which is why Budget left unused is never negative.
Sizing decides how much to take; what the move then earns is a separate calculation, and the forex profit calculator that nets the spread and commission out of a closed trade runs it from your entry and exit prices.
The increment that decides whether the trade exists
Every broker has a size below which an order is rejected. Two separate limits produce it, and this calculator reports the stricter one in Increment actually used:
- Unit step — the smallest move in raw units. A typical forex step is 1,000 units, one micro lot.
- Lot step — the smallest move in lots, printed from the dropdown on the right-hand pane. A step of 0.01 lets you trade 0.25 lots; a step of 0.10 forces you up or down to 0.20.
The effective increment is the larger of the two. On USD/JPY with a 1,000-unit step, a 0.01 lot step gives the same increment because 0.01 lots is exactly 1,000 units. Set the lot step to 0.10 and it becomes 10,000 units, and that is the number doing the rounding.
The consequence is visible in the numbers below. The same trade, the same 75.00 budget:
| Lot step | Increment used | Tradable size | Loss at stop | Budget left unused |
|---|---|---|---|---|
| 0.01 | 1,000 units | 25,000 units (0.25 lots) | 72.37 USD | 2.63 USD |
| 0.10 | 10,000 units | 20,000 units (0.20 lots) | 59.09 USD | 15.91 USD |
The looser step costs you 21% of your risk budget in size you are not allowed to take. That is not a rounding error, it is the whole of the difference between trading your plan and trading a version of it that fits your broker. The small-account walkthrough shows what happens when even one increment is too large for the budget.
Worked example: USD/JPY on a USD account
Assume a 5,000.00 USD account, risk of 1.5% per trade, USD/JPY trading at 155.20, a stop 40 pips away, a 1.2-pip spread, a 6.00 USD round-turn commission, and a broker dealing in 0.01-lot increments.
- Risk budget: 5,000.00 x 1.5% = 75.00 USD.
- Effective stop distance: 40 pips + 1.2 pips = 41.20 pips, which is 0.412 JPY at a pip size of 0.01.
- Convert to the account currency: 1 JPY is worth 1 / 155.20 = 0.00644330 USD, so one unit loses 0.412 x 0.00644330 = 0.00265464 USD if the stop is hit.
- Budget left after commission: 75.00 - 6.00 = 69.00 USD.
- Raw size: 69.00 / 0.00265464 = 25,992.23 units.
- Round down to the increment: 1,000-unit steps fit into that 25 times, giving 25,000 units = 0.25 lots.
- Check the worst case: 25,000 x 0.00265464 = 66.37, plus 6.00 commission = 72.37 USD, inside the 75.00 budget by 2.63.
Step 6 is the step that most tools leave out, and it is not cosmetic. Skipping both the costs and the rounding gives 29,000 units for this trade, and placing that size loses 82.98 USD at the stop — over the budget by 7.98, or about 10.6% more risk than you decided to take. Every trade sized that way carries the same hidden markup.
| Stop distance | Tradable size | Loss at stop | Ignoring costs: size and real loss |
|---|---|---|---|
| 20 pips | 50,000 units (0.50 lots) | 74.30 USD | 58,000 units, loses 85.23 USD |
| 40 pips | 25,000 units (0.25 lots) | 72.37 USD | 29,000 units, loses 82.98 USD |
| 60 pips | 17,000 units (0.17 lots) | 73.04 USD | 19,000 units, loses 80.92 USD |
| 80 pips | 13,000 units (0.13 lots) | 74.02 USD | 14,000 units, loses 79.25 USD |
Read the 20-pip row once more: 0.50 lots on a 5,000.00 USD account is 50,000 USD of exposure, ten times the account. It fits the risk only because the stop is very close. If your broker's margin rules cap you lower than the leverage field suggests, leverage is the constraint that bites next.
The same calculation in price terms, step by step
The panel above takes the stop as a pip count, because that is what a ruler on a chart gives you. The arithmetic underneath it is the same arithmetic in price terms, and it is worth doing once by hand so you can tell when an automated answer looks wrong. Four inputs are all it takes.
- Risk budget — the money you accept losing on this one trade: the balance times a percentage, or a fixed cash amount.
- Stop distance in price terms — the absolute difference between the entry price and the stop price, in the units the pair is quoted in.
- Spread — paid the moment you open, so it is part of what you lose if the trade goes straight to the stop.
- Commission — paid on the round turn whether the trade wins or loses.
Two details decide whether the answer is honest. The spread is added to the stop distance, because it is loss incurred at entry. The commission is subtracted from the budget, because money spent on fees is money that can no longer be risked. Rounding goes down, never to nearest, because rounding up silently increases the risk.
Worked example: EUR/USD in price terms
Take a 10,000.00 USD account at 1% risk, buying EUR/USD at 1.1000 with the stop at 1.0980, a 1-pip spread, a 7.00 USD round-turn commission, and a broker dealing in 1,000-unit steps.
- Risk budget: 10,000.00 x 1% = 100.00 USD.
- Stop distance: 1.1000 - 1.0980 = 0.0020, which is 20 pips.
- Effective stop distance: 0.0020 + 0.0001 = 0.0021.
- Budget left after commission: 100.00 - 7.00 = 93.00 USD.
- Units: 93.00 / 0.0021 = 44,285.71 units.
- Round down to the step: 44,285.71 / 1,000 = 44.28, floored to 44, so 44,000 units = 0.44 lots.
- Check the worst case: 44,000 x 0.0021 = 92.40, plus 7.00 commission = 99.40 USD, inside the 100.00 budget.
| With spread and commission | Ignoring both | |
|---|---|---|
| Position size | 44,000 units (0.44 lots) | 50,000 units (0.50 lots) |
| Real loss at the stop | 99.40 USD | 112.00 USD |
| Against a 100.00 budget | under by 0.60 | over by 12.00 (+12%) |
The shortcut is the familiar 100.00 / 0.0020 = 50,000 units, and it is wrong by a double-digit percentage: those 50,000 units lose 112.00 at the stop, not 100.00. Size every trade that way and the effective risk is not 1% per trade, it is 1.12% per trade, every single time.
The reason the two answers differ is that stop distance is not a constant. On the same budget with no costs, a 10-pip stop buys 100,000 units, a 20-pip stop buys 50,000 and a 40-pip stop buys 25,000 — one is four times the other for identical risk. That is why the size comes out of the calculation and the stop comes off the chart; fixing the lot size first and then hunting for a stop inverts the logic.
When the quote currency is not your account currency
The formula only works if both sides are in the same currency. With a USD account trading USD/JPY at 150.00, a stop measured on the chart is a JPY amount: one JPY is worth 1 / 150.00 = 0.006667 USD, so multiply the JPY stop distance by that and the rest of the formula is unchanged. The clean self-check is to compute the loss in the quote currency first and convert it once — if converting twice gives a different answer, one of the two conversions is inverted.
Mistakes that survive years of trading
- Sizing from leverage. Leverage gives the largest position your margin allows, which is a broker limit, not your limit. The smaller of the two is the one to use.
- Widening the stop after sizing. The size was derived from the distance. Move the stop further away and the correct size shrinks; keeping the old size risks more than your percentage.
- Ignoring commission on short timeframes. The tighter the stop, the larger the share of the budget fees consume. On a 5-pip stop with a 7.00 USD commission against a 100.00 budget, 7% of it is gone before the trade starts.
- One fixed lot size for every pair. A 20-pip stop on EUR/USD and a 20-pip stop on a JPY cross are different amounts of account risk.
- Not re-checking after rounding. Rounding down is safe, but the printed risk is then no longer exact — recompute the loss from the rounded size, which is what Max loss at stop does above.
One budget shape deserves its own page: a funded-account evaluation is this same arithmetic run against a fixed drawdown allowance and a daily limit rather than a percentage of your own money, and the prop firm page works through that case — the rules that disqualify you are limits on the loss, not on the size.
Using this page as an MT5 position size calculator
MetaTrader 5 has a Volume field in its order window and no field for the money you are willing to lose. Nothing in the platform divides a risk budget by a stop distance, so the number that goes into Volume is worked out before the window opens — by the calculator above, from four values MT5 already prints about the symbol.
Right-click the symbol in Market Watch and open Specification (some builds put it under Symbols, then Properties). Four rows in that dialog fill four fields here.
| MT5 row | EUR/USD | Field on this page | What it decides |
|---|---|---|---|
| Contract size | 100000 | Contract size | How many units a Volume of 1.00 means |
| Volume step | 0.01 | Lot step, unit step | The increment the size is rounded down to |
| Tick size | 0.00001 | Pip size | Ten ticks to a pip on a five-digit pair, one tick on a JPY pair |
| Tick value | 1.00 USD | A check on the pip value | One pip is ten ticks, so 1.00 lot moves 10.00 USD per pip |
Two of those rows decide the answer, and two are worth confirming rather than assuming. Contract size converts the Volume field into units: 0.17 typed on a 100,000 contract is 17,000 units, while the same 0.17 on a symbol with a contract size of 1 is a fraction of one unit. Tick value is the quickest check on your own pip value without opening a second tool — a pip is ten ticks on a five-digit pair, so a tick value of 1.00 USD means 10.00 USD per pip on a full contract, which is also 100,000 x 0.0001 worked from the other two rows.
Worked example: EUR/USD on MT5, 1% of a 5,000.00 USD account
- Risk budget: 5,000.00 x 1% = 50.00 USD.
- Effective stop: 25 pips to the stop plus a 1.0-pip spread = 26.00 pips, which is 0.0026 of price at a pip size of 0.0001.
- Account currency and quote currency are both USD, so one unit loses 0.0026 USD if the stop is reached, and no conversion is needed.
- Budget after commission: 50.00 - 5.00 = 45.00 USD, for a 5.00 round turn.
- Raw size: 45.00 / 0.0026 = 17,307.69 units.
- Round down to the step: a 0.01 volume step on a 100,000 contract is 1,000 units, and 1,000-unit steps fit into that 17 times — 17,000 units, which is 0.17 in the Volume field.
- Check the worst case: 17,000 x 0.0026 = 44.20, plus 5.00 commission = 49.20 USD, inside the 50.00 budget by 0.80.
Two shortcuts are available on a trade this size, and both cost more than they look. Move the volume step to 0.10 and MT5 accepts 0.10 — 10,000 units, losing 10,000 x 0.0026 = 26.00 plus 5.00 = 31.00 USD, leaving 19.00 of the 50.00 budget unused. Ignore the costs as well and you would type 0.20, because 50.00 / 0.0025 = 20,000 units: that order loses 20,000 x 0.0026 = 52.00 plus 5.00 = 57.00 USD, which is 7.00 more than you decided to risk. The increment section above explains why the rounding only ever goes down; this is what that rule is worth on one order.
The step is not 0.01 on every symbol, and the Specification dialog is where the difference turns up. All 67 forex pairs in the reference dataset behind this site carry a step of 1,000 units, which is 0.01 lots against a 100,000 contract. The 44 instruments below carry a step of 0.001, and because their contract size is 1, one step is a thousandth of the instrument rather than a thousand units of a currency.
| Symbol | Asset class | Quote | Pip size | Contract size | Unit step |
|---|---|---|---|---|---|
| BTCUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| ETHUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| SOLUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| XRPUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| ADAUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| DOGEUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| AVAXUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| LINKUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| DOTUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| TONUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| LTCUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| BCHUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| UNIUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| ATOMUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| TRXUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| XLMUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| NEARUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| APTUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| ARBUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| OPUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| SUIUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| ICPUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| FILUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| INJUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| AAVEUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| GRTUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| THETAUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| EOSUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| CHZUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| SANDUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| MANAUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| AXSUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| GALAUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| IMXUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| RUNEUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| TIAUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| SEIUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| PEPEUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| ORDIUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| WIFUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| BNBUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| ETCUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| VETUSDT | crypto | USD | 0.01 | 1 | 0.001 |
| Custom instrument | custom | USD | 0.0001 | 1 | 0.001 |
A finer step buys granularity, not permission to take more risk: the size still comes from the budget divided by the stop, and rounding down can only ever give up one step of loss. On EUR/USD at the stop above, that ceiling is 2.60 USD of a 50.00 budget at a 0.01 step and 26.00 USD at a 0.10 step — which is why the coarser setting left 19.00 unused. On a 0.001-step instrument the same ceiling is a thousandth of one unit of price, so a budget too small for a forex increment usually still fills there.
Questions traders ask about sizing on MT5
Does MT5 work out position size for me?
No. The order window checks a volume against the symbol's minimum, its maximum and its step, and against your free margin. It has no field for the money you meant to risk, so nothing in the platform can tell you whether a volume fits your stop. Work the size out first, then type it in — 0.17 on the example above.
Where do I put the answer?
In the Volume field of the order window, in lots: 0.17 for 17,000 units against a 100,000 contract. MT5 reports volume rather than a unit count, and it rejects anything that is not a multiple of the step. Set the stop loss on the same ticket, or right-click the open position afterwards and modify it.
Why does MT5 reject the volume I calculated?
Three separate checks, and only one of them is about the size your risk allows. The volume can be below the symbol's minimum, it can fail to be a multiple of the volume step, or the margin for it can exceed your free margin. The first two are what this page rounds down for; the third is a leverage question, covered on leverage against position size.
Do I need an EA or an indicator for this?
No. Everything the arithmetic needs is in the Specification dialog plus your own stop distance, and this page runs in the browser with nothing installed. An EA that reads the same four rows is quicker if you size from the chart, but it knows your stop no better than you do.
Using this page as an MT4 position size calculator
MetaTrader 4 asks for a Volume in lots and says nothing about the money you are willing to lose, so the number that goes into that field is worked out before the order window opens — from the same four rows the platform already prints about the symbol. MT4 and MT5 size identically; what differs is where the rows live and what the platform calls them.
| MT4 row | EUR/USD | Field on this page | What it decides |
|---|---|---|---|
| Contract size | 100000 | Contract size | How many units a Volume of 1.00 means |
| Volume step | 0.01 | Lot step | The increment the size is rounded down to |
| Minimal volume | 0.01 | Minimum lot | Whether a computed size under 0.01 is tradeable at all |
| Tick value | 1.00 USD | A check on the pip value | One pip is ten ticks, so 1.00 lot moves 10.00 USD per pip |
Volume in MT4 is lots, not units, which is the one place people lose a factor of one hundred thousand. This page prints both: read the lots figure for the Volume field and the units figure when you want to see what you actually own.
Worked example: EUR/USD on MT4, 1% of a 5,000.00 USD account
- Risk budget: 5,000.00 x 1% = 50.00 USD.
- Effective stop: 25 pips to the stop plus a 1.0-pip spread = 26.00 pips, which is 0.0026 of price at a pip size of 0.0001.
- Loss on one full lot: 0.0026 x 100,000 = 260.00 USD.
- Lots before rounding: 50.00 / 260.00 = 0.19231.
- Rounded down to the 0.01 volume step: 0.19 lots, which is 19,000 units.
- What the ticket actually loses if stopped: 19,000 x 0.0026 = 49.40 USD, leaving 0.60 of the budget unused.
Type 0.19 into Volume. MT4 checks it against the volume step, the minimum volume and your free margin; it does not check it against your stop, because there is no field for that.
The same arithmetic in a spreadsheet
Any spreadsheet does this in one cell. With the balance in B1, the risk percentage in B2, the stop in pips in B3, the spread in pips in B4, the commission in B5, and the pip size and contract size in B6 and B7:
The last argument is the unit step, so the result is units, not lots: 10,000.00 at 1% with a 20-pip stop, a 1.0-pip spread and 6.00 of commission returns 44,000 units, which is 0.44 lots and loses 92.40 plus the 6.00 commission if stopped. Divide by the contract size if you want lots instead, and floor to 0.01 rather than 1000 to land on a Volume the platform accepts. A spreadsheet is fine for one ticket; it is the rounding and the currency conversion that people drop when they rebuild this by hand, so check yours against the calculator above before trusting a number you typed twice.
What this page covers
The instrument list holds 131 instruments — 67 forex pairs including majors, minors and crosses, 4 metals, 3 energies, 12 index CFDs, 43 crypto futures quoted in USDT, plus entries for a stock ticker of your choosing and a fully manual instrument. For each one the pip size, contract size and unit step come from the open reference dataset published alongside this site, and each field is editable in case your broker quotes it differently.
Those specifications are typical retail defaults, not values published by an exchange. Contract size and minimum lot vary between brokers and occasionally between account types at the same broker, so check yours against the deal ticket before trusting a number produced here.
One forex detail is worth stating plainly: on pairs quoted in JPY a pip is 0.01 of price rather than 0.0001, and the conversion is handled automatically. When your account currency is the base currency of the pair — a USD account trading USD/JPY, or a euro account trading EUR/GBP — the conversion is derived from the entry price you type. When it is neither the base nor the quote of the pair, no rate exists on the page, and it says so in the note above the results rather than guessing one.
Units, lots and what people call this
Whether a platform asks for lots, units or contracts, it is asking the same question: how much of the base currency. This page answers in both, so a forex lot size calculator and a unit calculator are the same two fields read two ways. Because the stop is entered in pips rather than as two prices, it also behaves as a straightforward forex lot calculator when you already know how far your stop is from entry.
If you arrived here looking for how to calculate lot size in forex, or for the steps behind calculating forex lot size, it is the same three fields this page opens with: the money at risk, the distance to the stop, and the increments your broker accepts. Those two phrasings, the forex lot size calculator wording above, and the unit wording are all one question — how much of the base currency to take — so there is only one page for it here.
How much those pips cost at a given size is the other half of the question, and the pip calculator that prices one pip, a 1-pip spread and a 20-pip move works it out for your instrument and your account currency.
Two habits make the result trustworthy. First, enter the stop distance you will actually use, not the one you hope for — widening the stop after sizing is how a 1% trade becomes a 2% trade. Second, treat Max loss at stop as the number that matters: it is computed from the size you can actually place, so it already accounts for the spread, the fee and the rounding. That last check is what turns this from a trading position size calculator into a tradable instruction.
The lot size explainer covers what a standard, mini, micro and nano lot is if the vocabulary is new, and the full forex sizing walkthrough works the same arithmetic in price terms instead of pips.
FAQ
How many lots should I trade if I risk 1% per trade?
It depends entirely on the stop distance, which is why there is no fixed answer. Enter your balance, set the risk to 1%, and type the stop distance in pips: 1% of a 10,000.00 USD account with a 20-pip stop and no costs is 50,000 units, or 0.50 standard lots, and the same budget with a 100-pip stop is a tenth of that. Set the stop first, then read the size.
Why is the result smaller than the raw formula gives?
Two reasons, both shown on the results panel. The spread and the commission are taken out of your risk budget before sizing, and the size is then rounded down to the increment your broker accepts. The raw figure is also printed next to it, under Size if costs were ignored.
Does it work when my account currency is different from the pair?
Yes. If your account currency is the base currency of the pair, the conversion is derived from the entry price you entered. Otherwise type your own rate into Quote → account rate. If the page has no rate available at all, the note above the results warns you that the conversion has been treated as 1 to 1 instead of applying a rate it cannot know.
Can I use it for gold, indices and crypto futures?
Yes. Gold uses dollars rather than pips, so enter the stop distance as a pip count at a pip size of 0.01. Index CFDs and crypto futures come with their own contract sizes and steps already filled in, both editable.
Why does my small account show a size of zero?
Because the size your risk allows is below the smallest increment set in the panels above, and rounding down from there leaves nothing. Either risk more per trade, use a wider stop, or move to a broker that accepts smaller increments — the small-account page walks through that decision.
Do I need an account, and is anything uploaded?
No and no. There is no sign-up, no login and no pop-up. The whole page is one HTML file, one stylesheet and one script, and every calculation runs in your browser.
How do I enter the size in MT5?
Type the lots figure into the Volume field of the order window — 0.17 on the MT5 example, which is 17,000 units against a 100,000 contract size. MT5 checks that number against the symbol's volume step, its minimum and maximum volume and your free margin; it does not check it against your stop, because the platform has no field for the money you meant to risk. The Specification dialog is where the step and the contract size are printed.
Is this a forex position size calculator for MT4 as well as MT5?
Yes, and the answer is the same on both, because the platforms share the contract rows that decide it — contract size, volume step, tick size and tick value. What differs is only where those rows are printed and what they are called. The MT4 worked example above gives 0.19 lots for 1% of a 5,000.00 account with a 25-pip stop and a 1.0-pip spread.
Why does MT4 reject the size I typed?
Three checks, none of them about your stop. The volume must be a whole multiple of the volume step, at or above the minimal volume, and within the maximum volume for the symbol — and your free margin has to cover the margin the larger ticket needs. A size of 0.001 on a symbol whose minimum is 0.01 is rejected before risk is considered at all, which on a small account is the usual reason a perfectly sensible number comes back as "invalid volume".
Can I do this in Excel instead?
Yes. One cell does the whole thing: =FLOOR((B1*B2 - B5)/((B3+B4)*B6), 1000) returns units, where the arguments are balance, risk percentage, stop in pips, spread in pips, commission, pip size and unit step. The two things a spreadsheet version usually loses are the rounding to a step the broker accepts and the conversion when the account currency differs from the pair, so test yours against the calculator above before you rely on it.
Why do I get 0.44 lots instead of 0.50?
Because the costs are inside the calculation. Ignoring them stops at 100.00 / 0.0020 = 50,000 units, but those units lose 112.00 at the stop once the spread and the commission are paid, not 100.00. The spread lengthens the distance and the commission shrinks the budget, so the honest number is smaller: 44,000 units, or 0.44 lots, on the EUR/USD example above.
Do I round lots up or down?
Always down. Rounding up increases the risk above what you budgeted, and once rounding up feels normal the compounded drift is what actually breaks accounts. If rounding down costs you a meaningful share of the intended size, either the account is too small for that stop or the instrument should be one with a finer step.