Skip to content
All library documents

Adjusting Position Size After Stop-Loss and Take-Profit Closures

Article MQL5 code base

Summary

This MQL5 Expert Advisor example changes its next trade size according to why the previous trade closed. After a stop-loss exit, it doubles the volume; after a take-profit exit, it resets volume to the minimum allowed by the symbol. The article explains that an `OnTradeTransaction` event can inspect the deal reason, using the platform’s stop-loss and take-profit reason identifiers, to distinguish the two exit types.

The described logic applies only to closing deals for the configured symbol and magic number. The article characterizes the event reason as a direct way to identify the exit trigger, and notes that at the time of writing the EA could only be checked through a live chart run or debugging with real data. It does not provide backtest results or discuss the risk of escalating position size after losses. Doubling size after a stop can increase exposure quickly, while resetting after a win does not by itself establish a safe or profitable sizing plan.

Key ideas

  • The EA detects whether a closing deal resulted from a stop-loss or take-profit event.
  • A stop-loss closure doubles the next trade volume in the example.
  • A take-profit closure resets volume to the symbol’s minimum lot size.
  • The event check is limited to the configured symbol and strategy identifier.
  • The article reports no performance evidence and does not assess the risk of increasing size after losses.

Tags

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