The Closer – Short Description
The Closer is an MQL5 Expert Advisor that can automatically or manually close open positions and pending orders based on freely configurable rules. It displays a control panel on the chart, where you can make all the necessary settings.
1. Main Idea & Functionality
- Monitoring of account parameters such as Equity, Profit, Margin-Level/Deposit Load, prices, and much more.
- Close actions are triggered as soon as one or more predefined conditions are met.
- You can manually close all filtered positions at any time by pressing the corresponding button.
- Fallback mechanisms: if a close attempt fails, multiple retries are carried out (including configurable pauses).
Tip: Use the panel on the chart to set and activate trigger values. You can define multiple conditions simultaneously.
2. Configurable Triggers (Conditions)
- Equity: Close when the account’s equity (or a relative value in % or +/–) is reached.
- Profit: Monitoring of the total profit or loss of the account.
- Symbol Profit: Only close profitable or unprofitable positions of a specific symbol.
- Margin-Level / Deposit Load: Enable closing if the margin level goes below/above a certain threshold.
- Price Trigger: A specific price is surpassed or undercut.
- High/Low Range: The current price breaks through the high/low (close prices) of a specified period.
- Moving Average Penetration: The price crosses a moving average (optionally with standard deviation).
- Date / Time: Closing positions at a predetermined point in time.
All triggers can be activated either individually or in combination. As soon as one condition is fulfilled, the close action is executed.
3. Filters & Options
- Filter positions:
- Only Long or only Short.
- Only profitable (Profit) or only losing (Loss) positions.
- Symbol selection: Only the current symbol or all symbols.
- Delete pending orders: If required, any open pending orders can also be removed.
- Other actions:
- Close other charts (and thus potentially other Experts).
- Exit the terminal (completely close MetaTrader, end of the line, game over).
- Virtual SL/TP:
- Stop levels are not sent to the broker, but monitored “internally.”
- Positions are closed by a market order as soon as the virtual limit is reached.
Note: Activating multiple filters at once (e.g. “Long + Profit Only”) reduces the number of positions that actually get closed.
4. Trailing & Intervals
- Trail function: Activates dynamic “tracking” of certain triggers (e.g. Equity, Price) so that the trigger value moves in a more favorable direction.
- Timer: Checks are carried out at adjustable intervals (milliseconds). Additionally, you can enable a check on every tick (“Check on every tick”).
5. Main Workflow
- Initialization (OnInit):
- Starts the dialog window and sets default values.
- Monitoring (OnTick/OnTimer):
- Regular updates of account balance, prices, and indicators.
- Checks whether a trigger condition is met.
- If so, execution of the close action.
- Close Action:
- Selects positions according to the configured filters.
- Closes all matching trades, possibly pending orders first.
- Triggers alerts, emails, or push notifications (if configured).
- Optionally closes other charts or the entire terminal.
- Reset & Cleanup (OnDeinit):
- Shuts down the Expert panel and releases resources.
6. Practical Tips
- Regularly check the checkboxes and values. Activated triggers take effect immediately.
- Combine multiple conditions for more complex exit strategies (e.g. time limitation plus minimum profit).
- Use “Virtual SL/TP” to reduce broker transparency. However, keep in mind the risk of slippage if connection problems occur.
- In case of issues or network errors, “The Closer” will attempt to close the positions multiple times.
- Use caution with the “Close other charts” and “Close terminal” options if other Expert Advisors are running.
Conclusion: “The Closer” enables flexible and automated closing of positions based on various market and account criteria. Thanks to its configurable filters and options, you have full control over which positions to close and when the action is triggered.