Skip to content
FXNook HubBeta

Alex / Break Even and Partial Close Manager for MT4

MetaTrader 4Expert AdvisorMITCompiled · build 2425
AlexFirst version.build 2425v1.06 hours ago1 version
README

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

InputDefaultWhat it does
Trades to manageAll trades on this symbolAll trades, only one magic number, or only manual trades (magic 0)
Magic number0Used when you pick "Only trades with the magic number"
Move the stop to break-eventrueTurns the break-even step on or off
Break-even trigger150Profit in points that triggers the move
Lock10Points of profit locked beyond entry (must be below the trigger)
Close part of the trade oncetrueTurns the partial close on or off
Percent50Percent of the volume to close
Trigger measured inPointsPoints or R
Points mode trigger200Profit in points for the partial close
R mode trigger1.0Profit in R for the partial close
Slippage10Maximum slippage in points for the partial close

How to use it

  1. Copy FXN_BreakevenPartialManager.mq4 to MQL4/Experts (MT4) or FXN_BreakevenPartialManager.mq5 to MQL5/Experts (MT5). In the terminal use File > Open Data Folder to find these folders.
  2. Restart the terminal or right-click Expert Advisors > Refresh in the Navigator.
  3. 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).
  4. 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 Lock to 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

InputTypeDefaultNote
InpGroup1string=== Which trades ======== Which trades =====
InpScopeENUM_FXN_SCOPESCOPE_ALLTrades to manage
InpMagicint0Magic number (used with "Only trades with the magic number")
InpGroup2string=== Break-even ======== Break-even =====
InpUseBreakEvenbooltrueMove the stop to break-even
InpBeTriggerint150Profit in points that triggers the move
InpBeLockint10Points of profit to lock beyond the entry price
InpGroup3string=== Partial close ======== Partial close =====
InpUsePartialbooltrueClose part of the trade once
InpPartialPercentdouble50.0Percent of the volume to close
InpPartialModeENUM_FXN_PARTIALPARTIAL_POINTSTrigger measured in points or R
InpPartialPointsint200Points mode: profit in points that triggers the close
InpPartialRdouble1.0R mode: profit in R that triggers the close
InpGroup4string=== Execution ======== Execution =====
InpSlippageint10Maximum slippage in points for the partial close

How to use it

  1. Download the compiled file (or the source and compile it in MetaEditor).
  2. Put it in MetaTrader: File → Open Data Folder → MQL4 → Experts, then refresh the Navigator.
  3. Test it on a demo account before any real money.
  4. Want changes? Open a copy in your Lab and ask for them in plain words.