Skip to content
All library documents

Using Functors and Monoids to Set Position Size from Projected Stop Loss

Article MQL5 articles

Summary

The article applies category theory concepts to an MQL5 money-management example. It treats monoids as rule-based selectors for choices such as timeframe, lookback period, applied price, and indicator. Their selected values, together with a normalized indicator reading, become inputs to a multilayer perceptron. The network is trained to estimate a stop-loss gap, which is then converted into trade volume using tick size, tick value, free margin, and a user-defined risk allocation. A margin check and maximum-lot fallback are also described.

The example uses BTCUSD and an RSI-based entry and exit system, with Bollinger-band readings also discussed as an input option. The author frames the approach as experimental and notes that preliminary EA performance is highly sensitive to position sizing; the text also points to remaining hurdles before practical use. It does not establish that the neural estimate improves returns or risk-adjusted performance, and the excerpt gives no complete comparative results. The method should be treated as a design exploration rather than a validated sizing model.

Key ideas

  • Monoids select candidate trading inputs such as timeframe, lookback, and applied price.
  • A multilayer perceptron maps selected inputs and an indicator reading to a projected stop-loss gap.
  • The projected gap is converted into lot size using tick economics and allocated free margin.
  • The example includes a margin check with a maximum-lot fallback.
  • The proposed sizing approach is experimental and lacks reported evidence of improved trading performance.

Tags

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