How to size a trade from your risk in MetaTrader 5, including commission

29 October 2026, 19:45
Saleh Al-marri
0
7

It is easy to choose a stop loss first and then pick a volume that "feels right". A cleaner way is the other way round: decide how much you are willing to lose if the stop is hit, then let the stop distance and your costs give you the volume. This post walks through the steps and the MQL5 functions involved.

1. Decide the risk in money

Pick a fixed share of your balance or equity, for example 1%. On a 2,000 USD balance that is 20 USD. This is the planned loss if the stop is hit, under the assumptions below.

2. Use the right prices

A buy opens at the Ask and its stop is triggered by the Bid; a sell opens at the Bid and its stop is triggered by the Ask. If you take both prices from the chart line (usually Bid), the spread is left out and the loss is understated. Use the price the position will really open at, and remember that the spread is paid through these prices: OrderCalcProfit does not add it for you, and it does not include commission or swap either.

3. Measure the loss per lot at the stop

The loss for 1.00 lot between entry and stop depends on the contract size, tick value and the account currency. Do not estimate it from pips. MQL5 can calculate it with the broker's own symbol settings:

double entry = SymbolInfoDouble(_Symbol, SYMBOL_ASK);   // buy example: stop below entry
double stop  = entry - 500 * _Point;
double loss1lot = 0.0;
if(!OrderCalcProfit(ORDER_TYPE_BUY, _Symbol, 1.0, entry, stop, loss1lot))
  {
   Print("OrderCalcProfit failed: ", GetLastError());   // do not size without this figure
   return;
  }
double lossPerLot = MathAbs(loss1lot);                  // the result is negative for a loss

For a sell, use ORDER_TYPE_SELL, the Bid as entry and a stop above it. The result is an estimate in account currency at current prices and conversion rates, so recalculate just before you send the order.

4. Add the round-turn commission

On commission accounts you usually pay when the position opens and again when it closes. If your broker charges 3.50 per lot per side, the round turn is 7.00 per lot:

cost per lot = lossPerLot + round-turn commission per lot

Check how your broker charges: some quote per side, some per round turn, some charge the whole amount at entry, and some use minimums or tiers. If you take the figure from your History tab, add the entry and exit charges of a closed position and divide by its volume to get the round turn per 1.00 lot, in account currency. A Standard account often has no separate commission (the cost is in the spread); Raw or Zero type accounts usually do. If you hold positions overnight, swap is an extra cost on top. The division below assumes commission grows in proportion to volume; with minimum fees or tiers, work out the commission at the proposed volume and check the total again.

5. Optionally keep a slippage reserve

Market orders and stops are not always filled at the exact price. A small reserve per lot (for example the value of a few points) makes the plan more conservative.

6. Divide and round down

double risk  = 20.0;                     // planned loss in account currency
double commissionRT = 7.0;               // round turn per 1.00 lot, account currency
double slipReserve  = 0.0;               // optional, per 1.00 lot
double costPerLot = lossPerLot + commissionRT + slipReserve;
double step  = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
double vmin  = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
double vmax  = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
if(costPerLot <= 0.0 || step <= 0.0) { Print("Cannot size: invalid cost or volume step"); return; }
double lots  = MathFloor(risk / costPerLot / step + 1e-9) * step;   // never round up
lots = NormalizeDouble(MathMin(lots, vmax), 2);  // 2 = decimals of a 0.01 step
if(lots < vmin) { Print("The trade does not fit this risk"); return; }

If the result is below the minimum volume, the honest answer is that the trade does not fit your risk: skip it, or reconsider the setup. Do not move the stop just to make the numbers fit. Also check the free margin (OrderCalcMargin) before sending.

A worked example (illustrative numbers, volume step 0.01, no slippage reserve)

Balance 2,000 USD, risk 1% = 20.00 USD.

Loss for 1.00 lot at the stop (from OrderCalcProfit): 180.00 USD.

Commission 3.50 per side = 7.00 round turn per lot.

Cost per lot = 187.00 USD.

Volume = 20.00 / 187.00 = 0.1069 lots, rounded down to 0.10 lots.

Planned loss at the stop = 0.10 x 187.00 = 18.70 USD, inside the 20.00 USD limit.

Leaving the commission out gives 20.00 / 180.00 = 0.111, rounded to 0.11 lots, and a real planned loss of 0.11 x 187.00 = 20.57 USD, above the limit. The tighter the stop, the larger the share of the commission in the total cost per lot.

7. Check the order before you send it

Before sending, read the whole order once: symbol, direction, order type, volume, entry, stop, take profit and the estimated loss. Many costly mistakes are a wrong symbol or a misplaced stop line, not a wrong idea.

Stops are not guaranteed. Gaps and fast markets can make a loss larger than planned, so the result is an estimated planned loss under the stated assumptions, not a promise.

Related tool

I built Levelstead, a panel for MetaTrader 5, to do these steps for manual traders: you drag the entry and stop lines on the chart, and it uses OrderCalcProfit, the commission learned from your own closed trades (or asks you once on a new account), an optional slippage reserve, rounds the volume down and shows the full order for review before anything is sent. It gives no signals and does not trade on its own. It is in the MQL5 Market: https://www.mql5.com/en/market/product/205000

Questions about the calculation itself are welcome in the comments.