Skip to content
All library documents

Long Position Trailing Stops with a Fixed Parabolic SAR

Article MQL5 code base

Summary

This example modifies a long-position management routine to calculate a trailing stop using a Parabolic SAR style update. When the latest bar makes a new high, the routine advances a step value up to a configured maximum, then moves the stop upward from its prior level toward that high. It normalizes the proposed stop to the instrument’s price precision.

The stop is applied only when it improves on the existing stop, or when no stop is set, and remains below the current bid. A successful position modification updates the stop while retaining the take-profit level. The excerpt illustrates mechanics rather than a complete strategy: it gives no short-position counterpart, parameter values, exit evaluation, backtest, or evidence about effectiveness, slippage, and gap risk.

Key ideas

  • The routine updates a long position’s stop after the market makes a new bar high.
  • Its SAR-like step increases by a configured increment up to a maximum.
  • The proposed stop is normalized and must remain below the current bid.
  • The example does not provide performance evidence or define a full trading strategy.

Tags

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