Loading…

Synthetic Stop Executor

A real stop order sits on the broker's book, visible to the server and, on some symbols, only reachable outside a minimum distance that can be wide enough to defeat a genuinely tight stop. This EA takes the opposite approach: it never sends a stop order at all. It watches the bid or ask against a level it keeps entirely on the client side and, the moment that level is crossed, closes the position at market like a human reacting to the price. The virtual stop is adopted only once, computed from the position's own entry price the first time this EA sees a matching open position with no server-side stop attached - a position that already carries a real stop is left alone deliberately, so this never silently overrides protection you set another way. The level is written to a GlobalVariable keyed by the order ticket so it survives an EA reload or a terminal restart within the same install; without that, restarting the terminal would silently strip every position's protection at once. An optional trailing mode ratchets the level forward as price moves favourably, and only forward - it never loosens. Notes and limitations - This stop is virtual. It protects a position only while this EA AND the terminal are both running. If the EA is removed, the chart is closed, or the terminal loses connection or is shut down, the position is left with no stop at all until you attend to it some other way - this is the single most important thing to understand before relying on it. - GlobalVariables persist across a terminal restart but not across a reinstall or a Common\Files reset; treat the stored level as durable within one install, not as permanent storage. - Only positions with no existing server-side stop are adopted. A position that already has a real stop is left untouched by design. - Triggering closes the position at market, at whatever price is then available - there is no guarantee of the exact virtual level in a fast or gapping market, exactly like a real stop order in the same conditions.

Expert advisor · MT4 · v1.0 · Free

About Synthetic Stop Executor

Synthetic Stop Executor is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 9 settings, such as Stop distance pips, Magic filter and Manage all symbols. MQL source code included.

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

Settings

SettingDefaultWhat it does
Stop distance pips50Virtual stop distance from entry, in pips
Magic filter0Magic number to manage (0 = manage every stopless position in scope)
Manage all symbolsfalseManage positions on every symbol, not just this chart's
Use trailingfalseRatchet the virtual stop forward as price moves favourably
Trail pips30Trail distance once in profit, used only when InpUseTrailing is true
Slippage pips3Slippage tolerance, in pips
Max retries5Attempts per close before giving up
Retry wait ms500Pause between attempts, milliseconds
Cleanup interval seconds300How often to purge global variables left by closed tickets

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: Alerts · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria