Skip to content
All library documents

Fixed-Margin Position Sizing from Free Margin

Article MQL5 code base

Summary

This document describes a trading routine that sizes a position as a chosen percentage of the account’s free margin. The stated inputs are a stop-loss distance in pips and a risk percentage, and the example explains how the calculated buy volume is checked before an order is placed.

The process first calculates a lot size through a fixed-margin money management class, then passes that size to a trade-volume check to find an amount affordable with available funds. It opens the position if funds are sufficient and logs the calculated and affordable volumes otherwise. A periodic calculation loop is also described. The key limitation is that stop-loss distance does not affect the fixed-margin calculation, so the allocation is based on free margin rather than the loss that would occur if the stop were hit. The document gives procedural guidance but no performance evidence or full numerical example.

Key ideas

  • The method targets a position margin equal to a specified share of free margin.
  • It accepts stop-loss distance and a risk percentage as inputs, although stop distance does not affect the margin-based sizing result.
  • The calculated lot size is checked against the volume affordable with available funds before opening a trade.
  • The process logs sizing and account information and recalculates on a recurring tick cycle.

Tags

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