Time Decay Exit Manager
Every strategy has a rough holding-time window inside which most of its winners resolve. A trade still open well past that window has already missed its normal path to profit, and the naive response - leaving the original stop and target in place indefinitely - keeps full risk on a trade that has statistically become less likely to pay for it. This EA does not judge whether a trade should exist; it only reels in how much room it is given as it ages. Once a position passes InpUsefulHoldingMinutes, its stop and target begin shrinking on a straight line toward configurable floors (InpMinStopPips, InpMinTargetPips), fully reaching those floors after InpDecayWindowMinutes more. An optional InpForceCloseAfterMinutes closes the trade outright past a hard age limit regardless of decay state, for strategies that want a firm cutoff rather than an ever-shrinking bracket that never quite reaches zero. The baseline distances used for decay are whichever stop and target were already on the ticket the first time this EA noticed it - it never assumes it opened the trade itself, and it works equally well on a position opened by hand or by another EA under a different magic number. Decay is strictly monotonic: a recalculated candidate that is not actually tighter than what is already set is skipped, so running the check every 30 seconds by default never fights with a separate trailing tool that has already moved the stop further in the trader's favour. Notes and limitations - Only acts on a ticket that already has a stop and/or target set at the time it is first noticed; a trade with neither is left to decay only through the force-close cutoff, since there is nothing to tighten. - The baseline captured on first sight is whatever was in place at that moment, not necessarily the trade's original stop/target if this EA was attached partway through the trade's life. - Decay only ever tightens; it never widens a stop or target that a different tool has already improved. - A candidate that would land inside the broker's stop or freeze level is skipped for that pass and logged, not sent and rejected. - This EA never opens a new position; it only manages trades already open that match its filters.
Expert advisor · MT5 · v1.0 · Free
About Time Decay Exit Manager
Time Decay Exit Manager is an expert advisor (trading robot) for MetaTrader 5. It has a news filter. It has 11 settings, such as Useful holding minutes, Decay window minutes and Min stop pips. MQL source code included.
Files in the download: TimeDecayExitManager.ex5, TimeDecayExitManager.mq5, TimeDecayExitManager.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Useful holding minutes | 240 | Statistically useful holding time, minutes - decay starts after this |
| Decay window minutes | 240 | Minutes over which stop/target ramp down to their floor once decay starts |
| Min stop pips | 10 | Floor stop distance once fully decayed (pips) |
| Min target pips | 15 | Floor take-profit distance once fully decayed (pips) |
| Force close after minutes | 0 | Hard close age in minutes, 0 = never force close |
| Magic filter | -1 | Magic number filter (-1 = every magic) |
| Current symbol only | true | Restrict to this chart's symbol |
| Check interval sec | 30 | Seconds between decay scans |
| Max retries | 5 | Modify/close attempts before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
| Slippage points | 30 | Slippage tolerance for a forced close |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: News Trading · MT5 Expert Advisor · MQL5 Source Code