Loading…

Breakeven Manager

Moving a stop to breakeven after a trade has proven itself is one of the most common pieces of trade management, and one of the easiest to forget to do by hand in a fast market. This EA does exactly that one job: once a position has moved InpTriggerPips in profit, its stop loss is moved to the entry price, adjusted by InpBufferPips. The buffer input does double duty by its sign. A positive buffer moves the stop past entry in the profitable direction, locking in enough to cover the spread and commission so "breakeven" is a genuine breakeven rather than a guaranteed small loss once costs are counted. A negative buffer sets the stop short of entry, useful when the trigger distance is generous and a small give- back is preferable to breakeven arriving too early. The rule this EA is strict about is that a stop only ever tightens. Once breakeven has been applied, running the check again - which happens every tick by default - recomputes the same candidate and finds it no better than the stop already in place, so nothing is sent. That also means it is safe to run alongside a separate trailing stop tool: whichever one has moved the stop further in the trader's favour, the other's candidate loses the comparison and is skipped rather than overwriting the better stop. Notes and limitations - This EA never opens, closes or resizes a position, and it never moves a stop away from the position's favour. - A position with no stop loss at all is moved to breakeven as soon as it qualifies; there is no existing stop to compare against. - Applies once per position by design - after breakeven is set, the never-move-backward rule makes every subsequent pass a no-op unless a candidate is genuinely better (which cannot happen from this EA's own logic alone, only from a separate trailing tool improving the stop further). - Uses live Bid/Ask to judge profit, so the trigger is read against real-time price, never a value computed ahead of the tick that produced it. - A stop candidate that lands inside the broker's stop or freeze level is skipped and logged by ticket rather than sent and rejected. - On an MQL5 netting account, InpMagicFilter selects or excludes an entire symbol's net position, not individual trades within it - see MQL4 VERSUS MQL5 DIFFERENCES above.

Expert advisor · MT4 · v1.0 · Free

About Breakeven Manager

Breakeven Manager is a script for MetaTrader 4. It has 7 settings, such as Trigger pips, Buffer pips and Magic filter. MQL source code included.

Files in the download: BreakevenManager.ex4, BreakevenManager.mq4, BreakevenManager.txt.

Settings

SettingDefaultWhat it does
Trigger pips20Profit distance, in pips, that arms breakeven
Buffer pips0Buffer past entry, in pips (negative locks a small profit, positive covers costs)
Magic filter-1Magic number filter (-1 = every magic)
Current symbol onlytrueRestrict to this chart's symbol
Once per barfalseRe-evaluate only on a new bar, not every tick
Max retries5Attempts per modify before giving up
Retry wait ms500Pause between attempts, milliseconds

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Trailing Stop & Break-even · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria