{
  "id": 16439733,
  "title": "Moving a stop to breakeven in MQL5 without rejected modifies or hidden losses",
  "url": "https://urgent.news/2026/10/25/moving-a-stop-to-breakeven-in-mql5-without-rejected-modifies-or",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-25T06:30:03.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/omaisali/moving-a-stop-to-breakeven-in-mql5-without-rejected-modifies-or-hidden-losses-3o73"
  },
  "original_language": "en",
  "account": "Adjusting the stop loss to breakeven once a trade becomes profitable is a popular request for Expert Advisors. However, this simple feature often leads to numerous bug reports, with the stop loss not moving, journal entries filled with errors, or the trade closing at breakeven while still showing a small loss. This tutorial presents a comprehensive breakeven routine that accurately measures profit from the correct price, takes into account the broker's distance rules, ensures the stop is only tightened, and factors in trading costs.\n\nWhen calculating profit, it's essential to use the appropriate price for closing the position. For a buy position, the closing price should be the bid, while for a sell position, it should be the ask. Failing to measure profit from the correct price will result in the spread being counted as profit and the stop moving too early. This can be particularly problematic on symbols with wide spreads, as it may cause the stop to be moved before the trade is truly in profit.\n\nBreakeven is not the same as the entry price. If the stop is placed exactly at the open price, a trade that returns and hits the stop will still incur commission and any accumulated swap, resulting in a loss. Therefore, breakeven should typically be set at the entry price plus a small positive offset to account for commission and potential slippage. For a buy, this offset is added above the entry price, while for a sell, it is subtracted below the entry price.\n\nOn netting accounts, another consideration arises. When adding to an existing position, the POSITION_PRICE_OPEN becomes the volume-weighted average price of the entire position. Consequently, the breakeven level should move accordingly with each addition. While this is often the desired behavior, it's essential to test this functionality to ensure it works as expected.",
  "summary": "Moving the stop loss to breakeven once a trade is in profit is one of the most requested Expert Advisor features. It also produces a surprising number of bug reports: the stop never moves, the journal fills with errors, or the trade closes \"at breakeven\" and still shows a small loss. This tutorial builds a breakeven routine that measures profit from the right price, respects the broker's distance…",
  "key_points": [
    "Stop loss moved to breakeven upon profitability.",
    "Correct price used for profit calculation, bid for buy, ask for sell.",
    "Breakeven set above entry for buy, below for sell to cover costs."
  ],
  "editors_take": "Accounting for spreads, commissions, and volume-weighted entry prices transforms a simple stop-loss adjustment into a precise risk management tool that prevents hidden losses during automated trading.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}