Skip to content
All library documents

Designing a Trading Risk Class with Loss Limits and Dynamic Position Sizing

Article MQL5 articles

Summary

This article develops the foundational structure of an MQL5 risk management class. It organizes risk settings into enumerations and a shared loss and profit structure, with options for fixed monetary limits or percentages applied to account measures such as balance, equity, net profit, or free margin. It distinguishes daily, weekly, lifetime, and per-trade limits, and accounts for FTMO-style daily loss rules as a special case.

The class design includes assigning loss and profit values, retrieving risk information, scheduling daily or weekly resets, and calculating lot size from per-trade risk. It describes two dynamic sizing approaches: sizing from the risk allowance alone or adjusting volume to a specified stop distance. An example explains how ignoring stop distance can leave the actual stop-out loss below the intended risk amount. This installment is explicitly incomplete: it lays groundwork for later limit checks and actions, and says the class is not yet ready for live use.

Key ideas

  • Risk limits can be specified as fixed money amounts or as percentages of selected account metrics.
  • Daily and weekly loss or profit limits need periodic resets, while a lifetime maximum loss does not.
  • Dynamic lot sizing can use per-trade risk alone or adjust volume to the chosen stop-loss distance.
  • The article presents a class framework and value assignment methods, not a complete live-ready risk manager.

Tags

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