Unisciti alla nostra fan page
- Visualizzazioni:
- 161
- Pubblicato:
-
Hai bisogno di un robot o indicatore basato su questo codice? Ordinalo su Freelance Vai a Freelance

A take profit split in five steps for any open position on MetaTrader 5, on Gold (XAUUSD), EURUSD, indices or crypto. You set the distance of TP1 to TP5 in points or in multiples of the stop loss (R) and the percent of the initial lot to close at each one. The EA watches manual trades and positions opened by any other expert, filtered by magic number, and closes the partial the moment price reaches each level.
After the level you choose the stop loss moves to breakeven plus an offset, and an optional trailing stop follows price from there. A position with no stop loss can receive one automatically. The levels already taken are stored in terminal global variables, so a restart of the terminal does not repeat a partial close.
It never opens a trade. Partial volumes are rounded to the broker lot step, and when the remainder would be smaller than the minimum lot the position is closed in full. Run it on a demo account with your own symbols and your own lot sizes before using it on a live one.
Settings
Strategy
- TP distance mode: Points from entry, or Multiples of stop loss distance (R). In R mode a position without stop loss is ignored until it gets one.
- TP1 to TP5 distance: distance of each level in points (200 points = 2.00 USD on XAUUSD with 2 digits, 0.20 USD with 3 digits) or in R (1.0 = the same distance as the stop loss).
- TP1 to TP5 close percent: percent of the initial volume to close at each level. 20 / 20 / 20 / 20 / 20 closes everything in five steps. 50 / 50 / 0 / 0 / 0 closes in two. A level with 0 percent or 0 distance is skipped.
- Close the whole remainder at the last active level: the highest level with a percent above zero closes whatever volume is left, no matter its percent.
Close / Exit
- Move SL to breakeven after this TP level: 1 means right after TP1. 0 turns it off.
- Breakeven offset: points added above (buy) or below (sell) the entry price, to cover commission.
- Trailing stop after breakeven: with start, distance and step in points. It only starts once the breakeven level has been reached.
Risk Protection
- Add stop loss when the position has none: distance in points. 0 leaves positions without stop loss as they are.
Filters
- Positions to manage: chart symbol only, or all symbols of the account from one chart.
- Magic number to manage: 0 manages every position, manual trades included. Set the magic of another EA to manage only its positions.
- Manage buy / sell positions: switch each direction on or off.
Expert Settings
- Max slippage in points for the partial closes, status on chart as plain text, log every action to the Experts tab and an optional pop-up alert on every partial close.
What it needs
- MetaTrader 5, hedging or netting account. The partial close reduces the position volume and keeps the same ticket on both.
- Algo trading enabled. One chart is enough for the whole account when Positions to manage is set to all symbols, the EA runs on a one second timer as well as on ticks.
- It has no magic number of its own, the deals it sends keep the magic of the position they belong to, so the statistics of your other EAs stay intact.
Make it yours
Attach it to the chart where you trade by hand on Gold (XAUUSD), EURUSD, GBPUSD, US30, NAS100 or BTCUSD and let it take the partials while you watch the next setup. Put it next to a scalping or grid EA that only knows one take profit and give that EA five. In R mode it turns a stop loss into a risk reward ladder, 1R, 2R, 3R, that fits any Smart Money Concepts, supply and demand or support and resistance entry. The functions XP_CloseVolume, XP_BreakEven and XP_Trailing are self contained, copy them into your own expert advisor or trade manager when you need a partial close that respects the lot step and the broker stops level.
About this code
Open source. Use it as it is, adapt it, build your own version on top of it.
New versions and new tools are announced first on my MQL5 channel: https://www.mql5.com/en/channels/xander
Questions, suggestions and your own tests are welcome in the Xander Lab group: https://www.mql5.com/en/messages/02eec85e4364dd01
More tools on my profile: https://www.mql5.com/en/users/09151993a
Related
- Basket Pair Closer: closes the best winner together with the worst loser when the pair turns positive.
- XPro Trade Panel: manual entries, stops, breakeven and partial closes from one panel, MT5 and MT4.
- Grid XAUUSD and Gold Recovery: Gold expert advisors that can run with this manager on top.
Changelog
- v1.0 - 2026-10-25 - Initial release.
Swap Markup Scanner
Shows the broker's hidden financing markup and the carry for every symbol, as annual % of notional.
DataSnooping: SPA test, Reality Check, StepM and model confidence set
Is the best of many strategies really better than the benchmark? Hansen's SPA test, White's Reality Check, Romano-Wolf StepM and the model confidence set.
Broker GMT offset and daylight-time rule from price history
Detects the broker's GMT offset and its daylight-time rule (fixed, US or European) from the weekly closes in the H1 history, the same way live and in the Strategy Tester, with functions that convert New York times to server time and back.
ADX Auto Range
Range boxes that are drawn when market trend strength weakens