Loading…

Structure Trailing Stop Manager

This is a trade manager, not a signal generator - it opens no positions. Attach it to a chart that already carries an open trade (placed by hand, or by another EA sharing this one's magic filter) and it takes over trailing the protective stop. A fixed-pip trail applies the same distance regardless of what the market has actually done, which means it is often tighter than the last genuine swing (getting stopped out on ordinary noise) or looser than it (giving back more of an open profit than the structure justifies). This EA instead detects a "confirmed" swing point using a standard fractal test: a pivot bar's low (or high) must be the lowest (or highest) of a symmetric window of InpSwingStrength bars on each side of it. Because the window needs bars on both sides, a pivot is only confirmed once InpSwingStrength bars have closed AFTER it - the EA never acts on a swing that could still be invalidated by the next bar. Once a new swing point confirms, every open long managed by this EA gets its stop trailed up to the new swing low (minus a small buffer), and every open short gets its stop trailed down to the new swing high (plus the same buffer) - and only in the direction that tightens risk. The stop is skipped for one bar, not forced, whenever the new level would land inside the broker's minimum stop/freeze distance. Notes and limitations - This EA never opens or closes a position - it only ever tightens an existing stop. If no position is open, it just tracks swing points and waits. - The stop only ever trails in the favourable direction (up for a long, down for a short); it will never loosen an existing stop. - Swing detection starts fresh on attach - it does not replay chart history to find a swing that formed before the EA was loaded, so the first trail can take InpSwingStrength bars (or more) to arrive. - A confirmed swing point inside the broker's minimum stop/freeze distance is skipped for that bar and retried automatically once a later bar's price has moved enough to clear it.

Expert advisor · MT4 · v1.0 · Free

About Structure Trailing Stop Manager

Structure Trailing Stop Manager is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Swing strength, Buffer pips and Magic number. MQL source code included.

Files in the download: StructureTrailingManager.ex4, StructureTrailingManager.mq4, StructureTrailingManager.txt.

Settings

SettingDefaultWhat it does
Swing strength5Bars required on EACH side of a pivot to confirm it as a swing point
Buffer pips2.0Extra distance beyond the swing point the stop is placed at, in pips
Magic number-1Magic number to manage; -1 manages every position on this symbol regardless of magic
Max retries5OrderModify attempts before giving up on a single trail
Retry wait ms500Pause between retry attempts, milliseconds

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Buy/Sell Arrows · Trailing Stop & Break-even · Alerts · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria