Magic Profile Exit Manager
- Utilità
- Versione: 1.0
- Attivazioni: 5
Applies a separate R-based exit plan to each position by its magic number: break-even, two partial exits, ATR or R-step trailing, time stop and an optional protective stop. It does not open trades.
Magic Profile Exit Manager manages the exits of positions that are already open on your account. You can open them by hand, through another Expert Advisor, or with a trade panel. The utility looks at each position's magic number and assigns it to one of three exit profiles. Each profile has its own plan, measured in R. One R is the distance between the entry price and the first stop-loss the utility sees on the position.
The problem it solves
Most exit tools apply one set of rules to every trade on a chart. Many traders run manual trades and one or more Expert Advisors on the same account, and each needs different handling. A scalping EA may need an early break-even and a tight trail. Manual swing trades may need partial exits and a wider ATR trail. Another EA's positions may need only a protective stop. This utility applies the right plan to each position from one chart.
How a profile works
Each profile has a list of magic numbers. Use 0 for manual trades, * for any magic number, or a comma-separated list such as 1001,1002. A number written in a list takes priority over *. For each matched position the utility can:
- Move the stop-loss to break-even plus a small lock when profit reaches a set number of R.
- Close a percentage of the initial volume at a first and a second R target.
- Trail the stop-loss by an ATR multiple or by a fixed distance in R. The ATR uses the last closed bar, so the trail level does not repaint. The stop only moves in your favour.
- Close the position after a set number of bars if it has not reached a minimum profit in R.
- Add a protective stop-loss at an ATR multiple to positions opened without one.
Broker conditions
Before each request, the utility checks the stops level and freeze level. It skips requests that would not change anything. It rounds volumes down to the volume step and never leaves less than the minimum volume open. If a partial exit is too small to send, it is skipped and written to the log. If a request is rejected, the utility waits a set number of seconds before trying again. Completed stages are saved in terminal global variables, so a restart does not repeat a partial exit. Netting accounts are supported: there, a partial exit is sent as an opposite deal.
View only mode
In View only mode the utility sends no orders. It writes each action it would take to the Experts log, so you can check your settings on a live account before you switch to Live.
Panel
A small table lists each managed position with its profile, current profit in R and the stages already done. A Pause button stops all actions until you press it again.
Installation and setup
- Download the product from the Market into MetaTrader 5.
- Attach it to one chart only (any symbol). It manages all symbols unless "Symbols to manage" is set to Chart symbol only.
- Turn on Algo Trading and allow algorithmic trading in the program settings.
- Set the magic numbers and rules for each profile. Start in View only mode and read the Experts log.
- When the logged actions match your plan, switch to Live.
Strategy Tester demonstration
The demo version only runs in the Strategy Tester. In the tester, the utility opens a sample position on the test symbol with a stop-loss (minimum lot or four times the minimum lot, after a margin check), so you can watch break-even, partial exits and trailing in visual mode. On a live chart it never opens positions.
Limitations
- If a position's stop-loss is already at or past the entry when the utility first sees it, R cannot be measured and the position is not managed. The panel shows this.
- On netting accounts, adding to a position changes its average entry. The stored R distance and initial volume do not change.
- Partial exits cannot be carried out on positions at the minimum volume.
- Execution depends on your broker, connection and terminal. Requests can be rejected or filled at a different price. The utility does not work while the terminal is closed.
Testing performed
Version 1.00 compiles with no errors or warnings (MetaEditor build 6292). Helper and input-validation logic passed 22 offline unit tests. In the MetaTrader 5 Strategy Tester, using the sample positions the utility opens there, it completed runs on EURUSD H1 (OHLC on M1 and every tick), EURUSD M1, GBPUSD M30 and XAUUSD D1, plus EURUSD M1 and H1 with a 1 USD deposit. All runs finished normally with no errors in the journal. Separate tester runs checked the time stop, the R-step trail, the protective stop on positions opened without one, and View only mode (no orders sent). On a hedging demo account the utility loaded, recognised manual and EA positions and assigned them to the correct profiles. It has not been tested on a netting account.
Risk disclosure
Trading leveraged products carries a high level of risk and may not be suitable for all investors. This utility changes stop-loss levels and closes positions automatically according to your settings. Wrong settings can close positions earlier or later than you intend. Test it on a demo account first. Past results do not predict future results. The utility does not generate trade entries and does not promise any profit.
Inputs
General
- Execution mode: Live sends orders. View only logs intended actions.
- Symbols to manage: All symbols, or Chart symbol only.
- Scan interval, milliseconds: how often positions are checked (100 to 5000).
- Max deviation for closes, points: allowed slippage for close requests.
- Wait before retrying a failed action, seconds.
- Popup alert / Push notification on each executed action.
Profile A, B and C (the same set of inputs in each)
- Enabled.
- Magic numbers: 0 = manual, * = any, or a comma list.
- Break-even trigger (R), break-even lock (R beyond entry), extra points added to the lock.
- Partial 1 trigger (R) and size (% of initial volume). Partial 2 trigger (R) and size (%).
- Trailing mode (Off, ATR distance, Fixed distance in R), trailing start (R), ATR timeframe, ATR period, ATR multiplier, R-step distance, minimum SL improvement in points.
- Time stop after N bars, its timeframe, and the R level below which it closes.
- Add SL to positions without SL: ATR multiplier (0 = off).
Panel
- Show panel, X/Y offset, font size, maximum rows, text, header, warning and background colours.
Strategy Tester demonstration
- Tester only: open sample positions to show management.
- Tester only: sample SL distance as a multiple of ATR(14).
- Tester only: open samples without SL (used to show the protective stop).
Keywords
trade manager, exit manager, break even, partial close, trailing stop, ATR trailing, R multiple, magic number, risk management, position management, time stop, MT5 utility
