Log files are written records of all trading activity in MetaTrader. Whenever a trader submits an order, modifies a stop loss or connects to the broker, MetaTrader notes everything that happens along with the time.
We use log files to reconstruct a sequence of events when expert advisors run on a live account. Knowing the order in which things happened helps us to determine why an EA may not work properly.
Consider the logical steps where you want to go to the grocery store. If I were writing software to do this, my log file might read something like this:
1) Find my car keys
2) Find my wallet
3) Get in the car
4) Drive to the grocery store
5) Buy groceries
If my log file only says “find my wallet” and “get in the car”, I intuitively know that something is wrong. Why would the software not work when I get in my car? Because I don’t have my keys.
The log file helps your MQL programmer think along the same lines. When the log says, “calculate the entry rules” and the log only talks about the exits, it’s clear that the flow of the program doesn’t match the design intention.
Log files only come from the computer where the expert advisor runs. When a problem inevitably arises, your programmer will request that you send the log files from the computer where you’re running the EA. This is unfortunately a necessary part of the debugging process.
We do all of our quality assurance testing in the MetaTrader backtester. Although this usually catches the most obvious bugs, new errors will always pop up while forward testing the EA. The log file is what helps connect us to the problem, even though it happened on another computer.
Find your MetaTrader 4 log file
MetaTrader keeps two sets of log files. The most basic logs are located in YOUR BROKER NAME\logs. Most of our clients navigate here accidentally and assume it’s the file that we need. Expert advisors cannot write to this log file, so it unfortunately doesn’t do us much good.
Locating the correct log file for your programmer will vary based on your operating system. Anything in capital letters changes based on your personal information.
Windows XP and Windows Server 2003 users can find the logs in C:\Program Files\YOUR BROKER NAME\experts\logs
Expert advisors that run on Windows Vista or 7 have to put in more effort. Those log files are found in
C:\Users\YOUR USER NAME\appdata\local\virtualstore\Program Files (x86)\YOUR METATRADER INSTALLATION\experts\logs.
The part that confuses most Windows 7 users is that when they navigate to the folder with their USER NAME, the appdata does not appear as an option. The easiest trick is to double click on the current folder name at the top of the screen. Once you’ve clicked, the entire directory name will appear. If you type “appdata” after the final backslash and push enter, the window will navigate to the correct location. You can then continue clicking until the log file appears.
The name of the file corresponds to the date. The format is year, month and date (YYYYMMDD). Today is January 23, 2012, so the log file for today is named 20120123.log.
Finally, log files are often enormous – 50 MB or more. Please right click on the file and select “Compress” or “Send to, Zip File”. Sending the zip file can reduce the file size by 80% or more.