Account Event Journal
The Account History tab shows closed trades. It shows nothing about a deposit, a withdrawal, a credit adjustment, or a leverage change made on the broker's side - those simply change the numbers with no entry anywhere explaining why. Reconstructing "what happened to my balance overnight" after the fact means guessing. This EA polls account state on a timer, independent of price ticks, and classifies every balance change as either a TRADE_RESULT (matched against newly closed trades in history) or a BALANCE_OPERATION (a deposit, withdrawal or manual adjustment not explained by any closed trade). Leverage and credit changes are logged the moment they are observed. Margin level is watched against two user-declared thresholds - a margin-call level and a stop-out-risk level - and logged once on entry into stress and once on recovery, rather than flooding the log every poll while it stays there. Neither MQL4 nor MQL5 exposes the broker's actual stop-out percentage, so the "stop-out risk" threshold here is a value the trader sets to match their own broker's published SO level, not something this EA reads from the account directly. That limitation is stated plainly rather than pretending the number is authoritative. Two builds are provided from this folder: an MQL4 original and a native MQL5 port. Neither build places, modifies or closes a single order - both only read account state and trade history. Notes and limitations Balance-change classification is best-effort: it matches the balance delta against the summed profit/swap/commission of trades newly appearing in history since the last poll, within a small tolerance. A deposit that happens to land in the same poll window as a trade closing at almost the exact opposite value could misclassify - rare in practice, worth knowing about. The declared stop-out threshold is not read from the broker and must be kept in sync manually if the broker changes it. Neither build ever trades or modifies an order - both only read account state and history.
Expert advisor · MT5 · v1.0 · Free
About Account Event Journal
Account Event Journal is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Poll seconds, Margin call percent and Stopout risk percent. MQL source code included.
Files in the download: AccountEventJournal.ex5, AccountEventJournal.mq5, AccountEventJournal.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Poll seconds | 2 | How often to check account state, seconds |
| Margin call percent | 100.0 | Margin level %% at/below which a MARGIN CALL entry is written |
| Stopout risk percent | 50.0 | Margin level %% at/below which a STOPOUT RISK entry is written (set to your broker's SO level) |
| Alert on stopout risk | true | Pop a terminal Alert() when stop-out risk is logged |
| Log file name | AccountEventJournal.csv | File written under MQL5\Files\ |
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 → Scripts.
- 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 script onto a chart to run it once.
Tags: Alerts · MT5 Expert Advisor · MQL5 Source Code