What If Exit Simulator
Traders argue about exits from memory, which is exactly where the most comfortable answer wins. This tool re-runs history instead: for every closed trade matching the filters, it replays the symbol's own bars from the entry bar forward and checks when a fixed target, a trailing stop, or a fixed number of bars would have closed the position, then converts each hypothetical exit price into money using the account's own tick value and tick size, scaled by the trade's actual lot size - never a hardcoded contract size, so it prices gold, indices and FX consistently. The replay walks bar highs and lows, not tick-by-tick history, so a wick that briefly touched a level and a bar that closed straight through it are treated the same. That is a real approximation, not a tick-accurate backtest, and is stated here rather than implied to be more precise than it is. It is a comparison tool for spotting a structurally better exit rule across many trades, not a claim about the exact fill any single alternative would have received. The batch runs once, at attach, over the account's full matching history, and prints a per-trade line plus a totals comparison naming which alternative would have produced the most money over the sample. Notes and limitations - Approximates fills from bar highs/lows on InpReplayTimeframe, not from tick history. Treat the totals as directional evidence, not exact P&L. - A trade whose open time is not covered by locally available bar history on InpReplayTimeframe is skipped and counted, not silently dropped - the totals report how many were skipped. - The batch runs once at attach. Reattach the EA (or reload the chart) to replay again after new trades have closed. - Read-only. It never sends, modifies or closes an order.
Expert advisor · MT4 · v1.0 · Free
About What If Exit Simulator
What If Exit Simulator is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 7 settings, such as Magic filter, Symbol filter and Replay timeframe. MQL source code included.
Files in the download: WhatIfExitSimulator.ex4, WhatIfExitSimulator.mq4, WhatIfExitSimulator.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Magic filter | -1 | Trades with this magic number (-1 = every magic number) |
| Symbol filter | Only this symbol, "" = every symbol in history | |
| Replay timeframe | PERIOD_M15 | Bar granularity used to walk the price path |
| Target pips | 100 | Fixed-target alternative: distance in pips |
| Trail pips | 60 | Trailing-stop alternative: trail distance in pips |
| Time exit bars | 48 | Time-exit alternative: exit after this many replay bars |
| Max horizon bars | 500 | Hard cap on bars scanned per trade, bounds worst-case run time |
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: Trailing Stop & Break-even · Alerts · MT4 Expert Advisor · MQL4 Source Code