Rejected Order Archive
A trading account's history shows what filled. It does not show what tried and failed - the requote that got rejected, the stop that was too close to the market, the order that bounced off a disabled trading flag. Those failures still cost time and, over enough of them, missed opportunity, but MQL4 gives no built-in log of them once the terminal journal scrolls past. This Expert Advisor wraps every OrderSend and OrderClose call it makes through ArchivedOrderSend and ArchivedOrderClose helper functions. On any failure, it appends one row to a CSV archive: timestamp, the action attempted, the symbol, the requested order type, price, lot size, stop loss and take profit, which retry attempt it was, the raw broker error code, a plain-English description of that code, and the account balance and equity at the moment - the same context a trader would need to explain, after the fact, why a signal never became a position. Be clear about what this can and cannot do. MQL4 has no terminal-wide hook that lets one EA observe another EA's OrderSend calls, successful or failed - there is no cross-EA event to subscribe to. This program archives only ITS OWN trade attempts. It is not a monitor that watches other EAs on the chart or account. Anyone who wants the same archive for an existing EA needs to route that EA's own OrderSend/OrderClose calls through equivalent wrapper functions - copying the ArchivedOrderSend pattern into that EA's source is the only way to get coverage of its attempts, since there is no shared logging convention built into the platform. A future version of this idea across multiple EAs would need those EAs to agree on a shared file or exported function and deliberately write to it - that is a design choice for the EA author, not something this program can retrofit from outside. To generate real, non-trivial trade attempts to archive, the EA includes a small built-in demo strategy - a simple moving average crossover - switched off by default. Turn it on to see the archive populate during testing, or leave it off and use the ArchivedOrderSend/ArchivedOrderClose functions as a template inside your own EA's trade logic. Notes and limitations Archives only this EA's own trade attempts - it cannot see or intercept another EA's OrderSend calls, successful or failed, because MQL4 provides no such hook. Do not install this expecting it to monitor a different EA already running on the account; it will show nothing for trades it did not itself attempt. The demo strategy is a minimal MA crossover included only to exercise the archiving code end to end - it is not tuned for live trading and carries the normal risk of any automated strategy: it can lose money. Test on a demo account first if you enable it. The archive file grows without bound over time; there is no built-in rotation or size cap. Delete or archive the CSV manually if it grows too large for your review workflow. A failed OrderSelect inside ArchivedOrderClose (e.g. the ticket already closed on the server between selection attempts) is treated as "nothing to close" and is not itself archived as a failure, since no trade request was actually sent in that case.
Expert advisor · MT5 · v1.0 · Free
About Rejected Order Archive
Rejected Order Archive is an expert advisor (trading robot) for MetaTrader 5 based on Moving Average. It can size trades from your balance and risk percent. It has 11 settings, such as Run demo strategy, Fast ma period and Slow ma period. MQL source code included.
Files in the download: RejectedOrderArchive.ex5, RejectedOrderArchive.mq5, RejectedOrderArchive.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Run demo strategy | false | Run the built-in demo strategy (MA cross) to generate real attempts |
| Fast ma period | 10 | Demo strategy: fast MA period |
| Slow ma period | 30 | Demo strategy: slow MA period |
| Fixed lots | 0.10 | Lot size used by the demo strategy |
| Stop loss pips | 30 | Stop loss distance, in pips, for the demo strategy |
| Take profit pips | 60 | Take profit distance, in pips (0 = none) |
| Magic number | 20260802 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 3 | Attempts per trade action before giving up and archiving as failed |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
| Archive file name | RejectedOrderArchive.csv | Archive file name, written to the sandbox |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Risk & Lot Size · Moving Average · MT5 Expert Advisor · MQL5 Source Code