The article delivers AdaptivePSARTrail.mqh: a reusable header that lets an EA trail positions (its own or external, by symbol/magic) with an adaptive Parabolic SAR. The utility adapts the step from divergence, guards flips with a side check, and orders broker and improvement gates (stops/freeze, tick grid, break‑even, start and step thresholds). A calculation‑only build serves indicators, result codes aid logging, and a demo EA verifies the integration.
Part 4 of this series extracted the divergence logic into DivergenceEngine.mqh and demonstrated it in a small Adaptive Parabolic SAR EA. That article closed by pointing at something the demonstration had deliberately left alone. In most systems, Parabolic SAR is a trailing-stop tool rather than an entry trigger, and the same adaptive acceleration factor can be used to tighten or loosen a trailing stop on an already-open position from an Expert Advisor that knows nothing about this series. This part builds that. AdaptivePSARTrail.mqh is a header that an existing Expert Advisor can include to gain an adaptive Parabolic SAR trailing stop, and it can trail positions that it did not open.
Moving the stop to the current SAR level as each bar closes looks like the whole job. Two things make it more than that. Parabolic SAR changes sides. Its dots sit below price during an uptrend and above price during a downtrend, and the moment price crosses them, they jump to the opposite side. A position does not change sides with them, so at every flip the indicator briefly produces a level that cannot legally serve as a stop for the position it is meant to protect. A broker can also refuse stops that are arithmetically correct. There is a minimum distance from the price at which a stop may be placed, a separate distance within which an existing stop cannot be modified, and a tick grid on which the level must sit. The utility adds a rule of its own on top: a trailing stop never moves backwards. If these checks are treated as a single condition, the stop may stop moving with no clear reason.
Check out the new article: Building a Divergence System (Part V): Adaptive Parabolic SAR Trailing Stop Utility.
Part 4 of this series extracted the divergence logic into DivergenceEngine.mqh and demonstrated it in a small Adaptive Parabolic SAR EA. That article closed by pointing at something the demonstration had deliberately left alone. In most systems, Parabolic SAR is a trailing-stop tool rather than an entry trigger, and the same adaptive acceleration factor can be used to tighten or loosen a trailing stop on an already-open position from an Expert Advisor that knows nothing about this series. This part builds that. AdaptivePSARTrail.mqh is a header that an existing Expert Advisor can include to gain an adaptive Parabolic SAR trailing stop, and it can trail positions that it did not open.
Moving the stop to the current SAR level as each bar closes looks like the whole job. Two things make it more than that. Parabolic SAR changes sides. Its dots sit below price during an uptrend and above price during a downtrend, and the moment price crosses them, they jump to the opposite side. A position does not change sides with them, so at every flip the indicator briefly produces a level that cannot legally serve as a stop for the position it is meant to protect. A broker can also refuse stops that are arithmetically correct. There is a minimum distance from the price at which a stop may be placed, a separate distance within which an existing stop cannot be modified, and a tick grid on which the level must sit. The utility adds a rule of its own on top: a trailing stop never moves backwards. If these checks are treated as a single condition, the stop may stop moving with no clear reason.
Author: Solomon Anietie Sunday