Loading…

Breakeven Plus Costs Mover

"Move stop to breakeven" almost always means moving it to the entry price. That is not breakeven. Closing a position still pays the spread on the way out, and by the time a trade is old enough to be moved to breakeven it has usually already paid commission and accumulated some swap on the way in. A stop set at the raw entry price locks in a small guaranteed loss equal to those three costs, not a flat result. This script computes the entry price plus (or minus, for a short) the sum of whichever costs are switched on: the current spread, the commission already charged, and the swap accrued so far, each converted into a price distance using the symbol's own tick value and tick size - never a hardcoded contract size, so it is correct across FX pairs, metals and indices alike. Swap can run either direction; a credit swap reduces what is owed rather than adding to it. The new stop only ever tightens. If an existing stop is already better than the computed breakeven-plus-costs level, it is left alone rather than loosened. Before sending anything, the distance from the current market price is checked against the broker's stop and freeze level, and a position too close to price to hold that stop yet is skipped rather than sent and silently rejected by the server. By default a position is only moved once price has actually reached the true breakeven level. Moving the stop there before price gets there would guarantee an immediate stop-out on the next unfavourable tick, which is the opposite of what a breakeven move is for. Notes and limitations - Market positions only. Pending orders have no entry price or costs to measure yet. - Commission read from OrderCommission() reflects whatever the broker has charged so far on this ticket. Some brokers charge commission only on open, others only on close, others on both - the script cannot tell which policy is in force and simply reports what the terminal already knows. - Spread is measured at the moment the script runs. On a widening spread the actual cost paid later can be larger than what was priced in. - A position whose stop and freeze level make the true breakeven unreachable right now is skipped with a message rather than forced. - The script runs once when you run it. It does not trail the stop forward as price continues to move - that needs an EA.

Script · MT4 · v1.0 · Free

About Breakeven Plus Costs Mover

Breakeven Plus Costs Mover is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 9 settings, such as Current symbol only, Magic filter and Include spread. MQL source code included.

Files in the download: BreakevenPlusCosts.mq4, BreakevenPlusCosts.txt.

Settings

SettingDefaultWhat it does
Current symbol onlyfalseRestrict to this chart's symbol
Magic filter-1Magic number (-1 covers every magic)
Include spreadtrueAdd current spread cost to the offset
Include commissiontrueAdd commission cost to the offset
Include swaptrueAdd accrued swap cost to the offset
Extra pips0.0Extra pips of buffer beyond exact breakeven
Only if in profittrueSkip positions not yet past the new stop level
Max retries5Attempts per position 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 · Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria