Skip to content
All library documents

Calculating Position Size from Account Risk and Stop Distance

Article MQL5 code base

Summary

The document explains a position-sizing function that estimates lot volume from a chosen percentage of account balance and the distance to a stop loss. Its stated calculation first converts the risk percentage into an account-currency risk amount, then divides that amount by stop distance and tick value. The result is normalized to the instrument's permitted volume increment and constrained by minimum and maximum trade sizes. Examples show how the function might be called in an automated trading program and how inputs and results could be displayed for checking.

This is a risk-management utility, not a complete trading strategy, and the document reports no backtest or live-trading evidence. The calculation depends on broker and symbol specifications being correct, and its simple formula may not cover differences between points and pips, contract sizes, account currencies, commissions, slippage, or gaps. The examples also do not explain behavior for invalid or zero stop distances. Traders would need to verify units and instrument-specific tick-value behavior before relying on the returned lot size.

Key ideas

  • The function derives a risk amount from account balance and the selected risk percentage.
  • It divides the risk amount by stop distance and tick value to estimate position volume.
  • The calculated volume is adjusted to the instrument's lot step and its minimum and maximum limits.
  • Correct units and symbol specifications are essential, and trading costs or gaps can make realized losses exceed the estimate.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.