Skip to content
All library documents

Fixed Percentage Risk Position Sizing with Stop-Loss and Volume Checks

Article MQL5 code base

Summary

This trading example describes calculating a buy position size from a chosen percentage of account equity at risk and a stop-loss distance. It then checks whether the calculated size is valid and whether the account has enough funds to open it. If the risk-based size is unaffordable, the example reports both the intended size and the affordable volume. The article also describes retry behavior after failed order attempts so a failed operation does not force the system to wait through another full calculation cycle.

A Strategy Tester example uses EUR/USD on a one-minute chart with a stated deposit and test period. It reports a calculated first position size and a stop-loss loss close to the configured risk fraction, while a later position could not be opened for lack of funds. These are illustrative results from one setup, not evidence of robust performance. The author notes that a zero stop-loss setting yields the minimum allowed lot; this means the sizing logic depends on a meaningful stop distance and does not itself guarantee a maximum loss under gaps, slippage, or execution failures.

Key ideas

  • Position size is calculated from a chosen account-risk percentage and stop-loss distance.
  • The example checks the risk-based size against permitted volume and available funds before opening a trade.
  • Failed or unfilled order attempts decrement a counter to allow an earlier retry.
  • The reported tester example illustrates the calculation but does not establish broader performance.
  • A zero stop-loss setting returns the minimum permitted lot, so the risk estimate depends on a valid stop distance.

Tags

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