Discussing the article: "A Trailing Stop Engine in MQL5 Supporting Five Trail Methods Simultaneously"
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: A Trailing Stop Engine in MQL5 Supporting Five Trail Methods Simultaneously.
We implement CTrailingEngine, an interface-driven MQL5 engine that evaluates each registered position on every tick and applies one of five trailing methods: fixed-pip, ATR multiplier, Parabolic SAR, percentage-of-profit, or swing high/low. All methods share the ITrailMethod contract, so new trails plug in without engine edits. Strict improvement and a one-point guard block backward moves and no-change SLTP modifications.
Most EAs hardcode a single trailing-stop method (often a fixed pip distance) and apply it to every open position. That works as a baseline, but it ignores the diversity of trade types a real strategy produces. A breakout trade entered on a strong momentum candle needs room to breathe; a fixed 20-pip trail will stop it out on the first retracement. A tight scalp opened near a key level needs the opposite: a narrow trail that locks in gains before they evaporate. A trend-following position held for hours may be best served by something that accelerates as the trade matures.
The answer is not to pick one method and hope it suits all trades. It is to let each trade use the method best suited to why it was opened.
This article introduces CTrailingEngine, which runs five trailing-stop methods in parallel. Each registered position can use a different method. All five methods implement the same ITrailMethod interface: fixed pip, ATR multiplier, Parabolic SAR, percentage-of-profit, and swing high/low. The engine evaluates every registered position on every tick and calls PositionModify() only when the proposed stop is strictly better than the current one by at least one point. The SL never moves backward, and no redundant broker requests are issued.
Author: Ushana Kevin Iorkumbul