Skip to content
All library documents

Closing All Trades at Account-Currency Profit or Loss Thresholds

Article MQL5 code base

Summary

This document describes an expert advisor that closes open trades and pending orders when account-equity thresholds for profit or loss are reached. The thresholds are stated in account currency: a profit target should be above current equity, while a loss threshold should be below it. Setting a threshold to zero is described as disabling that action. The text warns that thresholds set on the wrong side of current equity can cause immediate execution, and that spread settings can affect whether positions are executed.

The document mentions error handling for failed order closures or deletions, code cleanup, and removal of chart objects when the advisor stops. It provides no backtest, execution examples, or protection guarantees. Its own notes flag volatile forex conditions and spread-related limitations; the described equity trigger and order handling should therefore be understood as operational behavior, not evidence of a reliable risk-control outcome. The source does not clarify details such as how floating profit, commissions, or multiple accounts are handled.

Key ideas

  • The expert advisor is intended to close trades and pending orders at account-currency profit or loss thresholds.
  • The profit threshold should be above current equity, and the loss threshold below it.
  • A zero threshold is described as inactive, while an incorrectly placed threshold can trigger immediate execution.
  • Spread settings may prevent some positions from being executed.
  • The description mentions order error handling but provides no testing evidence or guarantee of risk control.

Tags

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