Payout Window Risk Reducer
The days right before a scheduled payout are exactly when a trader is most tempted to push size to "lock in" the number, and exactly when a single bad trade does the most damage to a balance that has already qualified. This EA enforces a shrinking aggregate lot cap instead of leaving that discipline to willpower: full size is allowed outside a configured reduction window, and the cap falls in a straight line down to a protected minimum by the payout date itself. The schedule interpolates linearly rather than cutting straight to the minimum the instant the window opens - a sudden hard cut is itself the kind of erratic sizing change some funded programmes flag as unusual, so the reduction is gradual and predictable across the whole window. When current aggregate lots exceed today's cap, the EA can trim the excess automatically, largest position first, using partial closes normalised to the symbol's own lot step so no illegal fractional lot is left behind. If the remaining slice after a partial close would fall below the symbol's minimum lot, the position is closed in full instead of leaving an unbrokerable remainder. Automatic trimming can be switched off to run the EA as a warning-only panel instead. Notes and limitations This EA manages existing exposure; it does not place new trades and has no entry signal of its own. It checks that automated trading is currently permitted before attempting any trim (IsTradeAllowed() on MQL4; the three-way TERMINAL_TRADE_ALLOWED/ACCOUNT_TRADE_ALLOWED/ACCOUNT_TRADE_EXPERT check on MQL5) and warns instead of failing silently if it is off. The schedule is based on aggregate lots only, not risk in money terms - a portfolio of very different instruments may need a lower cap than the default to represent comparable risk. Reattaching the EA does not change the schedule, since it is anchored to the payout date rather than the attach time.
Expert advisor · MT5 · v1.0 · Free
About Payout Window Risk Reducer
Payout Window Risk Reducer is an expert advisor (trading robot) for MetaTrader 5. It has 9 settings, such as Payout date, Reduction window days and Max lots at window start. MQL source code included.
Files in the download: PayoutWindowRiskReducer.ex5, PayoutWindowRiskReducer.mq5, PayoutWindowRiskReducer.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 |
|---|---|---|
| Payout date | 2026.09.01 | Target payout/withdrawal date, format YYYY.MM.DD |
| Reduction window days | 14 | Days before the payout date when the schedule starts shrinking the cap |
| Max lots at window start | 5.0 | Permitted aggregate lots outside the window (full size) |
| Min lots near payout | 1.0 | Permitted aggregate lots on the payout date itself (protected minimum) |
| Magic filter | -1 | Magic number filter (-1 = every magic number) |
| Current symbol only | false | Restrict to this chart's symbol |
| Auto trim excess | true | true = partial-close matching positions down to today's cap; false = warn only |
| Max retries | 5 | Attempts per trim before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
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: MT5 Expert Advisor · MQL5 Source Code