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
| Setting | Default | What it does |
|---|---|---|
| Stop distance pips | 50 | Virtual stop distance from entry, in pips |
| Magic filter | 0 | Magic number to manage (0 = manage every stopless position in scope) |
| Manage all symbols | false | Manage positions on every symbol, not just this chart's |
| Use trailing | false | Ratchet the virtual stop forward as price moves favourably |
| Trail pips | 30 | Trail distance once in profit, used only when InpUseTrailing is true |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Attempts per close before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
| Cleanup interval seconds | 300 | How often to purge global variables left by closed tickets |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Alerts · MT4 Expert Advisor · MQL4 Source Code