You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: Building a Position Sizing Engine in MQL5 with Multiple Risk Models.
The article presents a position sizing engine for MQL5 Expert Advisors that separates risk policy from lot conversion. Four models—fixed fractional, fixed monetary, ATR-based volatility scaling, and equity-curve scaling—share a CLotConverter that uses OrderCalcProfit() to measure real money per point. A unified CPositionSizer interface exposes CalculateLots(), making model changes straightforward while producing broker-compliant volumes across symbols.
Two different questions hide inside "what lot size should I use":
Mixing these two ideas is exactly what makes sizing code fragile. A formula like balance * risk_pct / 100 / stop_points / 10.0 assumes a flat $10 per point value baked directly into the risk logic. That assumption holds for a handful of USD forex pairs and breaks on everything else. Switch the symbol to an index or a metal and the formula is simply wrong, even though the risk policy itself, "risk 1% per trade," never changed.
This engine keeps the two apart. Each risk model computes a risk_amount and hands it, along with a stop distance, to one shared CLotConverter. The converter's only job is turning that pair of numbers into a lot size the broker will accept. Adding a fifth model later means writing a small class that produces a risk_amount. The conversion math never needs touching.
Author: Ushana Kevin Iorkumbul