Scale Out Manager
This EA does not open trades. It watches a position, or a group of positions sharing one magic number, and closes a slice of it every time price advances a further InpScaleOutStepPips beyond the group's reference open price. Each slice is InpScaleOutPercent of the ORIGINAL group size recorded at adoption - not of whatever remains open - so a fixed schedule such as 25% four times empties the position exactly, instead of shrinking it by a smaller and smaller amount forever. The naive version of this closes a percentage of the CURRENT remaining size at each stage, which never actually finishes and leaves an unpredictable amount on the table. Anchoring every stage to the size recorded when the group was first adopted avoids that, and any stage that would leave a sliver below the broker's minimum lot instead takes the whole remainder rather than trying to leave an unclosable dust position. The base position is not opened by this EA - it is adopted. Open a position by hand, or with any other EA, tagged with InpMagicNumber, and this manager picks it up on its next scan and starts tracking milestones from its open price. Optionally, after the first stage fires, every remaining ticket in the group has its stop tightened to no worse than the reference open price - never loosened - so the runner that is left after scaling out can no longer turn into a loss on the ground already covered. Notes and limitations - If more than one ticket already exists under InpMagicNumber when this EA is first attached, the oldest ticket's open price becomes the reference for every pip milestone, and the combined lots of every matching ticket becomes the "original" size the stage percentages are taken from. - Partial closes are taken oldest ticket first. If a stage's percentage spans more than one ticket, several tickets may be partially or fully closed in the same pass. - A large favourable gap between scans can earn more than one stage at once - the EA fires every stage that has been earned in a single pass, up to InpMaxScaleOuts, rather than one stage per scan only. - This EA never closes a losing position and never adds to one. It only reduces the size of a position that is already in the requested direction of profit.
Expert advisor · MT5 · v1.0 · Free
About Scale Out Manager
Scale Out Manager is an expert advisor (trading robot) for MetaTrader 5. It opens a grid of orders at fixed price steps, moves the stop loss behind price (trailing stop / break-even) and has a news filter. It has 9 settings, such as Magic number, Scale out step pips and Scale out percent. MQL source code included.
Files in the download: ScaleOutManager.ex5, ScaleOutManager.mq5, ScaleOutManager.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 |
|---|---|---|
| Magic number | 20260704 | Magic number identifying the position group to scale out |
| Scale out step pips | 30 | Favourable move required, in pips from the reference open price, before each stage fires |
| Scale out percent | 25.0 | Percent of the ORIGINAL group size closed at EACH stage |
| Max scale outs | 3 | Maximum number of scale-out stages - a runner is left after the last one |
| Move stop to breakeven after first | true | Tighten every remaining ticket's stop to no worse than the reference open price after stage 1 |
| Slippage pips | 5 | Slippage tolerance on partial and full closes |
| Max retries | 5 | Attempts per order action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
| Scan interval sec | 10 | Seconds between scans |
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: Grid · Trailing Stop & Break-even · News Trading · MT5 Expert Advisor · MQL5 Source Code