Skip to content
All library documents

A Modular MQL5 Position Sizer with Four Risk Models

Article MQL5 articles

Summary

This article describes a reusable position sizing engine that separates risk policy from the conversion of risk into lots. It presents four policies: fixed fractional risk based on balance, a fixed cash amount, volatility scaling in which ATR informs stop distance, and equity curve scaling that cuts risk during drawdown. A common result structure reports both target and realized risk after volume rounding.

The shared lot converter uses OrderCalcProfit() to estimate money per point for each instrument, then applies broker volume limits and step sizes. The article explains why hardcoded pip values can mis-size indices, metals, and non-USD accounts, and includes example components and a demo EA. Its stated checks include synthetic tests for the converter and models, but the supplied text is incomplete and does not show benchmark or live-trading results. It also identifies missing margin checks, portfolio-level aggregation, and persistent drawdown tracking as limitations.

Key ideas

  • Separate the rule that sets the risk budget from the instrument-specific lot conversion.
  • Fixed fractional, fixed monetary, ATR-based, and drawdown-scaled policies can share one converter.
  • OrderCalcProfit() provides a broker-aware way to estimate money per point.
  • Report target risk and realized risk because broker volume increments can change the final exposure.
  • The described engine lacks built-in margin awareness and portfolio-wide risk aggregation.

Tags

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