Kelly Position Sizing from Historical Trade Outcomes
Summary
This article describes an MQL5 position sizer that estimates a strategy’s win probability and average win-to-loss ratio from its closed deal history, then applies the Kelly criterion to calculate a capital fraction. The proposed class filters deals by symbol and optionally by magic number, includes profit, swap, and commission in each outcome, and declines to estimate an edge when the sample is too small. It converts the chosen fraction into lots using account equity, stop distance, and the symbol’s tick value and size. A multiplier allows fractional Kelly sizing.
To illustrate why full Kelly can be too aggressive in practice, the article simulates a known even-money edge across a range of sizing multipliers, tracking terminal growth, maximum drawdown, and large equity losses. It reports that growth peaks at full Kelly while drawdown continues to rise, arguing for a smaller fraction when the edge is uncertain. The simulation assumes a stationary edge, fixed payoff, and one position at a time. Historical estimates may not predict future performance, and correlations or overlapping positions are outside its scope.
Key ideas
- The Kelly fraction is derived from win probability and the average payoff relative to the average loss.
- The proposed MQL5 class estimates those inputs from closed deal history, including swap and commission.
- A minimum trade count guards against sizing from a very small sample.
- A multiplier below one applies fractional Kelly, reducing the risk fraction from the full estimate.
- The simulation shows a growth and drawdown trade-off under fixed, stationary assumptions, which may not hold for real strategies.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.