Exp_ToCloseLoss
This EA monitors the account's floating profit/loss and closes all open positions (both long and short) across all symbols when the account loss exceeds a user-defined maximum loss threshold. It uses a global variable as a one-time trigger flag to prevent repeated closing attempts once the threshold is breached.
Open the interactive view (equity curve, symbol switch)Key facts
Backtest results (H1, about 1 year)
Not backtested yet — this EA could not be converted automatically.
Strategy analysis
The EA's strategy concept is an account-level loss protection utility rather than an independent trading strategy. It has no entry conditions and does not open positions on its own; it only triggers a full position closure when the account's floating loss exceeds the configured MaxLoss parameter. The exit condition is: when AccountInfoDouble(ACCOUNT_PROFIT) is less than or equal to -MaxLoss, a global variable flag is set to 1, and upon detecting this flag in OnTick, the EA iterates through all positions and closes them one by one. In terms of position sizing, the EA does not involve lot size calculation or position scaling logic. For money management, it relies solely on the single MaxLoss parameter as the maximum tolerable loss amount, without considering risk control based on account balance percentage. The EA uses a global variable as a state lock to ensure the closing operation is executed only once after the loss threshold is triggered, resetting only after all positions are closed and the global variable is deleted. However, there is no check for whether the close operation succeeds, no retry mechanism, and the slippage is hardcoded to 10 points.
Strengths
- Simple and intuitive loss protection mechanism that prevents excessive account drawdown
- Uses a global variable as a state lock to avoid repeatedly triggering closure logic while in a loss state
- Automatically resets the trigger flag when all positions are closed, allowing monitoring to restart
Weaknesses
- No close order success check or retry mechanism; network latency or insufficient liquidity could cause closure failures
- MaxLoss is a fixed amount rather than a percentage of account balance, requiring manual adjustment for different account sizes
- Slippage is hardcoded to 10 points, while different symbols and trading environments may require different slippage settings
- Does not account for the impact of spreads and commissions on actual losses
- In fast-moving markets OnTick may not execute quickly enough; lacks a timer-based backup mechanism
Possible improvements
- Add close order result checking and retry logic to ensure all positions are actually closed
- Change MaxLoss to support percentage mode (based on account balance/equity) for better adaptability across different account sizes
Risk assessment
Overall risk: Medium
- No success verification on close operations; in extreme market conditions positions may not fully close, resulting in losses exceeding expectations
- Fixed amount stop-loss does not scale with account size; small accounts may trigger too late while large accounts may trigger too early
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
MaxLoss | 1000.00 | Max allowed loss (currency); closes all positions when floating loss exceeds this value |
Similar Utility EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.