Skip to content
All library documents

MQL5 Stop-Loss Trailing Methods Using Price and Indicators

Article MQL5 code base

Summary

This MQL5 library provides reusable classes for managing stop losses on open positions. A simple trailing method maintains a fixed offset from price, while indicator-based methods can follow levels from Parabolic SAR, adaptive and exponential moving averages, and other listed indicators. A value-based class accepts user-supplied stop levels. The examples show the general integration pattern: initialize a class with the symbol and relevant settings, enable it, then call its run method during tick handling or for a selected position ticket.

Shared settings include the symbol, magic number, stop offset, trailing activation threshold, movement step, spread multiplier, and an active switch; indicator classes also take their own parameters. The document is implementation guidance, not a trading strategy evaluation: it provides no comparative results, rule for selecting a trailing method, or evidence that any method improves returns. Live behavior and suitability depend on the EA’s position handling, instrument constraints, and parameter choices.

Key ideas

  • The library offers fixed-distance, indicator-based, and custom-level stop trailing classes.
  • Indicator choices include Parabolic SAR and several moving average variants.
  • A typical integration initializes and activates a class, then calls it during tick processing.
  • Common controls include trailing start, step, offset, and spread handling.
  • The document explains software integration but does not compare trading performance.

Tags

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