Stop Target Change Recorder
MT4's terminal shows a ticket's stop-loss and take-profit as they stand right now. It does not show what they were five minutes ago, or an hour ago, or before a trailing routine last touched them. For anyone auditing their own trading after the fact - was a stop moved to breakeven at the right moment, did a trailing EA actually behave the way it was supposed to, was a manual edit responsible for a trade going wrong - that history simply is not there once it has been overwritten. This EA keeps it. Every tick it snapshots the stop-loss, take-profit and pending price of every tracked order, compares the snapshot against the one from the previous tick, and appends one row per changed field to a CSV log - the ticket, the symbol, which field changed, and the before and after value, timestamped. Nothing is inferred about who made the change or why; it is a plain factual record of what value replaced what value and when, which is exactly what "audit trail" means and exactly what the terminal's live-only display cannot provide. Detection is snapshot-and-diff on every tick, since MQL4 has no trade- event callback that would push a modification notice on its own - polling and comparing against the last known state is the only reliable way to catch a change the instant it happens rather than losing it between checks. Notes and limitations - This EA does not trade. It is read-only with respect to the account and safe to run alongside any other EA or manual trading. - A filled pending order's price is not recorded as a "change" - only a genuine modification of a still-pending order's price is; the fill itself is a different event this EA does not currently record. - Detection happens on the tick cycle. Two edits to the same field between two consecutive ticks would only show as one net change, not each intermediate value. - The CSV is opened once at startup and held open (flushed after every write) rather than reopened per row, for efficiency; it is properly closed in OnDeinit. - Tracking state (what the previous snapshot looked like) lives only in memory - restarting the terminal or removing the EA from the chart does not lose already-written log rows, but does mean the very next change after a restart is compared against a freshly rebuilt baseline rather than the true prior state.
Expert advisor · MT4 · v1.0 · Free
About Stop Target Change Recorder
Stop Target Change Recorder is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Log file name, Magic filter and Alert on change. MQL source code included.
Files in the download: StopTargetChangeRecorder.ex4, StopTargetChangeRecorder.mq4, StopTargetChangeRecorder.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Log file name | StopTargetChangeRecorder_Log.csv | CSV file in MQL4\Files\ |
| Magic filter | -1 | Only record this magic number, -1 = record every order |
| Alert on change | false | Also pop an Alert() for every recorded change |
| Max tracked | 500 | Maximum tickets tracked at once (array ceiling) |
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