If you ever been using MetaTrader 4 platform I am sure at some point you faced some issues. As a programmer I know that any software can fail from time to time, but most computer programs are designed in such a way that they will print out error, warning or any other informational messages for the user so (s)he could understand what’s going on.
Earlier I have wrote about troubleshooting expert advisors on MetaTrader 4, but another important thing is to know how to properly read log files to find the cause of the problem.
If you are one of those users who hit their computer every time they face trouble with any of the Expert Advisors, indicators or scripts on MetaTrader 4 platform, I am sure you’ll find this blog post very useful.
Being an MQL4 programmer for the last 7 years I know pretty well how to identify what’s wrong with one or the other MT4 app, but I also do know that many people don’t know how to do this. I literally receive hundreds of email messages every month where people face trouble with some MT4 EA and they cannot figure it out.
Do not get me wrong, but it looks like majority do not even try to find what cause of the problem, and I must say that’s understandable because there’s not much information about how to do this.
So let’s dig in. I would be wrong if I say that MT4 will record all your activity and later you can track down what was wrong at a certain moment, but I am definitely right if I’d say that MT4 will log the most important actions. In most cases that’s more than enough to understand what’s going on.
There are three types of log messages in the MetaTrader 4 platform and they are separated in different tabs at the bottom of the terminal, the Experts tab and the Journal tab, and another Journal tab in the MT4 Strategy Tester. But in this article I am going to talk about the messages in the Experts and Journal tab. I will leave backtesting log messages for another article 😉
All those messages are also written to special log files. We will get to that later. But first let me show you what you can find in the Experts and Journal tabs which in most cases helps to identify the cause of any EA trading problem without the need to dig deeper in to the log files.
The Experts tab
The Experts tab holds messages associated with the Expert Advisors, Indicators or Scripts you are running in the MT4 terminal.
For example, when the trade open request is sent by the EA, it will always be reported in the Experts tab. The same applies for any other trading action performed by the EA or Scripts. Indicators are not allowed to perform trading operations, they cannot open, modify or close the trades, but anything related with MT4 Indicators will also be logged in this tab.
Obviously any EA, Indicator or Script can be programmed to print out custom messages as well. These messages will always appear in the same Experts tab too. However, you can clearly see which messages were printed by an EA and which were printed by the MT4 terminal to inform about something related to the EA.
In the picture above you can see two messages have a “yellow triangle” image on the left while others have a “gray circle” image. The ones with the “gray circle” image are printed by the EA. In other words EA was programmed to print them in order to give more information to the user about what’s going on or what has happened at that certain moment. It’s kind of EA telling you what it is doing.
Imagine a security guard visiting each floor of the building and filling in some special journal about his activity. Floor 1, checked at 10:02 AM. Floor 2, checked at 10:04 AM. Floor 3, checked at 10:06 AM, etc. Anyone who will read his journal later will know which floors he have checked and at what time.
The “yellow triangle” picture indicates that this message is related to some sort of a trading operation and it was printed by the MT4 client terminal, but it kind of came from the EA as well. In other words EA does not have any choice to avoid printing these messages. So any time EA performs a successful trading operation (like trade open, close or modification) it will be logged by the MT4 with that “yellow triangle” on the left.
Imagine additional security guards on each floor filling in their journals as well about that main security guard visiting them. Security guard on the 1st floor fills in his journal “Main guard visited 1st floor at 10:02 AM”. Then the second guard fills in his journal “Main guard visited 2nd floor at 10:04 AM”.
In the example above you saw one “yellow” message is about the trade opening and the other is about trade modification. There is no way for the EA to avoid printing these messages.
Now let’s take a look at how you can find out which EA actually printed the message.
As you see Experts tab has two columns. The first one is “Time” and there is no need for any explanation there. I will just mention that this is the time of your computer. So if your broker server’s clock (in the Market Watch window) is on a different timezone, its time will not match with the time printed in the Experts tab.
The second column says “Message“, but it kind of holds more than that. You can notice that the message starts with the name of the EA (or indicator, or script) and in our example we see two different Expert Advisors printing messages. “LTC Client VIP v2.6” is the name of the first EA and “Myfxbook” is the name of the second EA (messages at the top are the most recent messages).
This way you can easily identify which EA printed the message and this basically tells you which EA performed one or the other operation. For example from this example above we can clearly see that the LTC Client EA opened a sell trade #18662944 of a lot size 0.85 on the EURAUD currency pair at a price of 1.38578. There are no doubts about that and no matter what other people can tell you the Experts tab messages don’t lie. This trade was opened by the LTC Client EA, period.
Next, after the EA name, comes an instrument name of the chart on which that particular EA is running. From the picture above it is clearly seen that the LTC Client EA is attached to the EURUSD H1 chart.
Normally EAs are programmed in such a way that they will only trade for the same currency pair of which chart they are attached to, but in this case Local Trade Copier EA is designed to open, modify and close trades on any pair. And as for the Myfxbook EA running on the same type of chart, it does not matter to which currency pair it is attached to, it will still do it’s job.
Important to note that MetaTrader 4 terminal does not allow to attach more than one Expert Advisor to any chart, so if you want to run multiple EAs on the same MT4 terminal you’ll have to open additional chart window for each EA.
Obviously, those can be chart windows of any currency pair or trading instrument. In our example above both EAs are running on EURUSD H1 type of chart window, but those are actually different windows, they are just of the same currency pair and time frame.
Actually, the fact that a user can run the same EA on other charts of the same trading instrument made it difficult to understand which EA actually printed the message, because they both show the same “EURUSD H1” (or whichever pair it would be) in the Experts tab. So to solve this problem I have improved my LTC Client EA to print a special unique ID of the chart window it is running on.
This instance of the Client EA has been assigned ID of 73588-6000-1. In case there would be other Client EAs running on the same currency pair name it would be impossible to tell which EA printed the message. But in my case both Client EAs would have different IDs assigned and it would help to identify who printed the message.
This ID consists of a special unique number (73588), the Magic Number assigned to the EA (60000) and a Signal Provider ID (1). If you happen to be a user of my Local Trade Copier software you’ll understand what this means 🙂
You can see that the “yellow triangle” messages does not have that ID and it’s because EA does not print those message by itself as I explained above. This is why there is no way for me to add such message ID, but it still helps with identifying other messages.
In the image above you can see two EAs loaded on different chart windows of the same currency pair and time frame (GBPUSD, M5) and both of those EAs printed messages in the Experts tab. Normally you would not be able to know which EA printed the message exactly because they both run on the same type of chart, but thanks to that unique message ID my apps are using, it is easy to identify which EA exactly printed the message. One EA uses message ID [84073-222-1] while the other EA uses message ID [30815-111-1].
If you happen to be an MQL4 programmer you might consider adding such feature to your EAs. It really helps when reading log files. If you ask how I generate unique ID for each chart window my answer is, I don’t. I use special MQL4 function ChartID.
Reading EA messages
Generally anything after the chart instrument and time frame (in image below it is EURUSD, H1) is the message generated by the EA. Literally it can be anything, but do not freak out if you see lots of messages. If you want to know what’s going on on your MT4 account and what EA is doing you should simply read those messages to better understand the situation.
In the image above we can see Myfxbook EA printed the message “Statement uploaded successfully“. So what does that mean? My guess would be that EA wants to inform us that the statement was uploaded successfully to the Myfxbook database. Yep, simple as that 🙂
You’ll notice that in the Experts tab recent messages are at the top while older messages are at the bottom. So in other words you need to track messages from bottom to top to maintain the right order of messages. However, in the log file, as you’ll notice later, messages are sorted by time. This means older messages are at the top and you should read them from top to bottom.
If we look closer at the LTC Client EA in the image above we’ll see that it opened a sell trade, modified it and then printed a series of informational messages about the connection delay, price deviation, trade number of the master trade and also trade number of the copied trade so it would be easier to identify them if needed.
What about errors? Using one of my EAs I have tried to open a trade of 800 lots. Let’s see what happened.
In the image above we see Trader on Chart EA generated a 134 error which means “Not enough money”, or in other words the lot size of the trade is too big for current account balance. Now this ToC app will also play a sound alert which lets user know that something is not right, but by looking into the Experts tab we can easily identify the actual cause of the problem.
Furthermore, EA will also print a label on the price chart that holds the error code so more experienced users can quickly identify why the trade was not opened.
Obviously those error code labels are not available with all the Expert Advisors out there, this is something I have added to the code of my apps, so don’t expect other EAs to print this.
oe134 error code stands for “Open Error 134”. This means there was an error 134 when opening a trade.
Mostly all EAs these days prints at least an error code in the Experts tab so you can use that to identify a possible cause of the problem. Click here for a full list of possible error codes.
Here’s another example of an error message.
I have set the Trader on Chart app to place a BUY STOP pending order at 0.70000 on NZDUSD pair. However, this pending order was not placed because at that moment current NZDUSD Ask price was 0.75207.
Buy Stop pending order entry price should always be above the Ask price and it is impossible to place it below that price (it should be BUY LIMIT if to place it below Ask price). So for this simple reason EA printed simple error message which says “Incorrect BUY STOP entry price 0.70000” and then there also are Ask and Bid prices logged for the record.
If all this sounds confusing to you I encourage you to read my blog post about market prices and different types of orders.
The Journal tab
The other type of messages, anything that is not generated by MT4 apps, are stored in the Journal tab. These are the messages about MT4 platform upgrade, server connection, any attempt to perform trading action manually or automatically and obviously broker server responses that in many cases helps to understand what problem you are facing.
Remember that 800 lot trade? When broker server denied to open such trade a message about that was sent to the EA and we saw error message logged about this. But also we see that in the Journal tab there is another error message printed.
This one comes directly from the broker server and it would be printed regardless if that error was caused by manual trading or automated trading. This error message also clearly states that there was not enough money to open a buy order of 800 lots on NZDUSD pair at market price.
Journal tab is divided in two columns as well: Time and Message. No explanation needed for those, but what I like about error log messages is that they will show that little red circle image on the left side which helps us to spot error messages easily.
I must mention that I do not pay a lot of attention to the Journal tab, because mostly I trade using EAs and all the messages I need are in the Experts tab in that case. But you should not underestimate the information printed in the Journal tab. It is worth looking into if you cannot find explanation anywhere else.
The Log files
Log files basically store the same messages you find in the Experts and Journal tab, but obviously log files can store a lot more messages. When you close and reopen MT4 platform you’ll see that there will be no messages in the Experts/Journal tabs. They start fresh and any older messages are now stored in the log files.
Normally it takes some time for the messages to be transferred from the Experts/Journal tabs to the log files in real time, so if you want to find the most recent messages in the log files you should close your MT4 platform and give it a few seconds.
Messages from the Experts tab are printed to the log files located at \Data Folder\MQL4\Logs\
Messages from the Journal tab are printed to the log files located at \Data Folder\logs\ (these files does not help much when solving problems with EA trading)
“Data Folder” can be opened from your MT4 platform by going to “File -> Open Data Folder“. This is where you can find all the log files, EAs, indicators, script and other files stored.
Once “Data Folder” is opened you can navigate inside the MQL4 folder and then Logs folder. This is how Experts log files look on my computer.
You can see that each log file name is a date in a format YYYYMMDD. This helps easily to find what you are looking for. However, keep in mind that because of the time zone difference between your computer and your broker the log file from 20150413 might not have some messages from the previous or the next day.
So, if someone asks you to send them log file from 13th of April 2015 I recommend you to send three log files: 20150412.log, 20150413.log, 20150414.log. Basically you should include log files from the previous day and the day after.
Reading a log file
When you open a log file in any text editor like Notepad or Notepad++ you’ll see all messages that were recorded on that particular day. Important to note that there’s a limit to how long a message can be in the Experts tab, but there’s no limit (or it is quite big to notice) to how long messages can be in the log file. So if you find some message truncated in the Experts tab you can simply find a full message printed in the log file.
In the picture above you can see an example of how this looks like. Basically the format is the same as in the Experts tab except that “yellow triangle” images are converted to number 2 and “gray circle” images are converted to number 0.
Next we have Time, EA name, chart instrument and time frame, and finally the message.
Another easy way to access log files is to click a right mouse button anywhere inside the Experts tab and choose “Open“.
Doing this in the Experts tab will open you a folder with the Experts log files, while doing this in the Journal tab will open you a folder with the Journal log files.
Other choices from this menu are self-explanatory, but I particularly like these options: Copy, View and “Auto Scroll“.
“Auto Scroll” option is something I use rarely, but when I have trouble with some EA that prints enormous amounts of log messages, turning “Auto Scroll” can be helpful. It simply allows you to look at the messages instead of seeing them scrolling down fast automatically which does not even give you time to read what they say.
Copy option simply copies selected messages to a clipboard so you can paste them in other applications. This allows you to avoid sending full log file and simply copy and paste a few messages with error codes and send them to software support team. Of course there might be cases when full log files is still required, but in many cases only few messages can help solve a problem.
View option allows you to filter through Experts log messages. Here’s the window it will open.
What’s cool about this feature is that you can enter a phrase you want to find, choose a date range and MT4 will search all Experts log files to find any message that has your phrase.
In the example above I enter trade number 18831445, chose a date range of the last two days, and once I hit Request button I get messages with that particular trade number.
How to send many log files as one file
The trick here is very simple. In order to send many log files as one file you need to pack them into a so called ZIP archive. This is very easy to do on any Windows machine. All you need to do is to open Logs folder, select files you want to pack, then click a right mouse button and from the menu choose “Sent to -> Compressed (zipped) folder“.
In the image below you can see how a .zip archive with compressed files look like. Seven log files compressed and packed into a single .zip file that can now be sent by email. It also save space. Those 7 files were 105 KB total and this .zip archive is 12 KB only.
To extract .zip archive you need to click the right mouse button on the file and from the pop-up menu choose “Extract All…“.
By simple reading messages in the Experts or Journal tabs on your MetaTrader 4 platform you can easily identify and solve problems associated with your Expert Advisors, indicators and scripts. Many people quit too soon or waste days trying to solve the problem with the help of software support team. Obviously there will be cases when you cannot solve the problem by yourself, but in most cases by just looking at those messages and using common sense can help you save hours of your time and get your MT4 apps running again.
Was this helpful? Share this piece of information with your friends and post your comments below.