Overview
Moves the stop to break-even plus locked points after a set profit and can close a percent of the trade at a profit in points or R.
Two classic trade-management steps in one small EA. When a trade reaches a set profit, it moves the stop loss to the entry price plus a few locked points, so a winner cannot turn into a full loss. Optionally it also closes part of the trade once, at a profit in points or in R, while respecting the broker's minimum lot.
How it works
On every tick it checks each open trade on the chart's symbol that matches Trades to manage (all, one magic number, or only manual trades with magic 0).
Break-even. When profit reaches Break-even trigger points, the stop is moved to entry + Lock points for a buy (entry - Lock for a sell). It only moves when that is better than the current stop, keeps the broker stop level, rounds to the tick size and waits if the freeze level blocks a change.
Partial close (once per trade).
- Points mode: when profit reaches Partial trigger points, it closes Percent of the volume.
- R mode: R is the distance between entry and the first stop loss. When profit reaches R x that distance, it closes Percent of the volume. The first stop is remembered when the EA first sees the trade (MT5 can also read it from history).
- Volume is rounded down to the lot step. If the part left open would be below the minimum lot, the closed part is reduced; if even that is not possible the trade is left whole and a message is printed once.
- MT5 netting accounts use an opposite deal and then restore the stop and target. A trade that was already reduced is not cut again; on MT4 the rest of a partly closed trade (comment "from #") counts as done.
Inputs
| Input | Default | What it does |
|---|---|---|
| Trades to manage | All trades on this symbol | All trades, only one magic number, or only manual trades (magic 0) |
| Magic number | 0 | Used when you pick "Only trades with the magic number" |
| Move the stop to break-even | true | Turns the break-even step on or off |
| Break-even trigger | 150 | Profit in points that triggers the move |
| Lock | 10 | Points of profit locked beyond entry (must be below the trigger) |
| Close part of the trade once | true | Turns the partial close on or off |
| Percent | 50 | Percent of the volume to close |
| Trigger measured in | Points | Points or R |
| Points mode trigger | 200 | Profit in points for the partial close |
| R mode trigger | 1.0 | Profit in R for the partial close |
| Slippage | 10 | Maximum slippage in points for the partial close |
How to use it
- Copy
FXN_BreakevenPartialManager.mq4toMQL4/Experts(MT4) orFXN_BreakevenPartialManager.mq5toMQL5/Experts(MT5). In the terminal use File > Open Data Folder to find these folders. - Restart the terminal or right-click Expert Advisors > Refresh in the Navigator.
- Drag it onto a chart of the symbol you trade, set the inputs and allow algo trading (AutoTrading button on MT4, Algo Trading on MT5).
- A common start: partial close 50% at 1.0 R and break-even at about the same distance with 10 locked points. With 0.01-lot trades a 50% close is not possible (minimum lot), so only break-even will act.
Good to know
- R mode needs a stop loss on the trade. If you attach the EA after the stop is already at break-even, R cannot be measured and the partial close is skipped for that trade.
- It works on the chart's symbol only; use one copy per symbol.
- It does not trail the stop beyond break-even; pair it with a trailing stop manager for that.
- Commission and swap are not included in the break-even level; raise
Lockto cover them.
Trading carries risk. Test on a demo account first; past results do not predict future results.
At a glance
- What it is
- A free Expert Advisor for MetaTrader 4, written in MQL4.
- What it does
- Moves the stop to break-even plus locked points after a set profit and can close a percent of the trade at a profit in points or R.
- Shared by
- Alex
- Licence
- MIT
- Version
- 1.0 (1 Dec 2026)
- Settings
- 15 inputs
- Lab check
- Compiled with MetaEditor build 2425 for MT4 on 1 Dec 2026: 0 errors, 0 warnings.
- Price
- Free to download
Settings read from the code
| Input | Type | Default | Note |
|---|---|---|---|
| InpGroup1 | string | === Which trades === | ===== Which trades ===== |
| InpScope | ENUM_FXN_SCOPE | SCOPE_ALL | Trades to manage |
| InpMagic | int | 0 | Magic number (used with "Only trades with the magic number") |
| InpGroup2 | string | === Break-even === | ===== Break-even ===== |
| InpUseBreakEven | bool | true | Move the stop to break-even |
| InpBeTrigger | int | 150 | Profit in points that triggers the move |
| InpBeLock | int | 10 | Points of profit to lock beyond the entry price |
| InpGroup3 | string | === Partial close === | ===== Partial close ===== |
| InpUsePartial | bool | true | Close part of the trade once |
| InpPartialPercent | double | 50.0 | Percent of the volume to close |
| InpPartialMode | ENUM_FXN_PARTIAL | PARTIAL_POINTS | Trigger measured in points or R |
| InpPartialPoints | int | 200 | Points mode: profit in points that triggers the close |
| InpPartialR | double | 1.0 | R mode: profit in R that triggers the close |
| InpGroup4 | string | === Execution === | ===== Execution ===== |
| InpSlippage | int | 10 | Maximum slippage in points for the partial close |
How to use it
- Download the compiled file (or the source and compile it in MetaEditor).
- Put it in MetaTrader: File → Open Data Folder → MQL4 → Experts, then refresh the Navigator.
- Test it on a demo account before any real money.
- Want changes? Open a copy in your Lab and ask for them in plain words.