Loading…

Trade Journal Auto Logger

Reconstructing a trading history from the terminal's own history tab is slow and loses the moment-by-moment detail - when a stop was moved, not just where it ended up. This EA polls the order pool the same way the rest of this catalogue's trade-event watchers do and writes a CSV row for every open, close, and (optionally) SL/TP modification it detects, each row timestamped and carrying the full order detail available at that moment. The file-handling decision is the one worth explaining. Opening a CSV file with FILE_WRITE truncates it - so a version of this EA that reopened the file for every single event would erase the whole journal down to one row, every time. This EA opens the file exactly once, in OnInit, seeks to the end of whatever is already there, and keeps the handle open for its entire run, flushing after each write. A restart appends to the existing journal rather than starting a new one or destroying it, and the header row is only written the first time the file is created, not on every attach. Notes and limitations - Detection is poll-based, not instant: an event is logged within InpCheckIntervalSec of happening, not at the exact tick it occurred. - If a trade opens and closes again within the same poll interval, only the CLOSE row is written - the OPEN state was never observed as distinct. - CLOSE and OPEN/MODIFY rows share one column layout; columns that do not apply to a given event type (ClosePrice, CloseTime, Profit, Swap, Commission on an OPEN or MODIFY row) are left blank rather than filled with a misleading placeholder. - Reattaching the EA seeds tracking from whatever is currently open; on both platforms this logs an OPEN row for every pre-existing trade found at that moment, since nothing was tracked before the attach. - The file uses a comma delimiter and is written with FILE_CSV, so any comment text containing a comma is quoted automatically by MetaTrader's CSV writer. - This EA only observes and logs. It never opens, closes or modifies a trade itself.

Expert advisor · MT4 · v1.0 · Free

About Trade Journal Auto Logger

Trade Journal Auto Logger 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 Log file name, Log open and Log close. MQL source code included.

Files in the download: JournalLogger.ex4, JournalLogger.mq4, JournalLogger.txt.

Settings

SettingDefaultWhat it does
Log file nameTradeJournal.csvFile name under MQL4\Files
Log opentrueLog a row when a trade opens
Log closetrueLog a row when a trade closes
Log modifytrueLog a row when SL/TP changes on an open trade
Symbol onlyfalseOnly track trades on this chart's symbol
Magic filter0Only track this magic number (0 = all magic numbers)
Check interval sec3Seconds between polls of the order pool

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria