Skip to content
All library documents

Close All Symbol Positions at Profit or Loss Thresholds

Article MQL5 code base

Summary

This note describes a simple expert adviser that closes all open positions for the chart’s symbol when aggregate profit reaches a configured take-profit amount or loss reaches a configured stop-loss amount. Its two settings define those thresholds: the profit threshold triggers closing on gains, while the loss threshold is specified at or below zero and triggers closing on losses.

The description cautions that swap and commission affect the threshold calculation: they reduce realized profit and increase losses. It provides no code, execution details, examples, or performance evidence, so it does not establish how positions are grouped, how quickly orders are closed, or how slippage and fees are handled in practice. The approach is a symbol-level exit rule rather than a complete entry or portfolio strategy.

Key ideas

  • A configured profit threshold can close all positions for the chart’s symbol.
  • A loss threshold at or below zero can trigger closing the symbol’s positions.
  • Swap and commission affect the net profit or loss used by the thresholds.
  • The description gives no performance evidence or implementation details.

Tags

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