Skip to content
All library documents

MQL5 Trailing Stops and Break-Even Stop Methods

Article MQL5 articles

Summary

This article describes reusable MQL5 helpers for managing open positions with trailing stops and break-even stops. It explains the difference between a trailing distance, which sets how far a stop follows price, and a trailing step, which sets how much price must move before the stop is updated. The fixed-point example activates after a position reaches a profit threshold, then places the stop at a specified distance from the current bid or ask. The article also outlines alternatives based on moving averages, ATR, Parabolic SAR, money amounts, and periodic updates, alongside fixed-point and monetary break-even approaches.

The code examples show position filtering by symbol and magic number, checks for broker stop-level constraints, and safeguards against undesirable stop modifications. The article presents these as development utilities rather than a complete trading strategy, and gives no performance evidence. Results depend on the chosen parameters, broker rules, execution conditions, and trading costs; break-even placement at entry also does not account for commissions or slippage.

Key ideas

  • A trailing distance sets the gap between market price and the stop, while a step controls how often the stop changes.
  • Fixed-point trailing logic can activate after a position reaches a chosen profit threshold.
  • Indicator-based alternatives use moving averages, ATR, or Parabolic SAR to determine stop levels.
  • Position-management helpers should account for symbol and magic filters and broker stop-level rules.
  • Moving a stop to entry does not guarantee a zero net result after costs and slippage.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.