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 the 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  😉

Experts and Journal tabs at the bottom of the MT4 client terminal. This is where MetaTrader logs all of the messages to inform user what's going on.
Experts and Journal tabs at the bottom of the MT4 client terminal. This is where MetaTrader logs all of the messages to inform the user what’s going on.

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 into 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.

Two different types of messages in the MT4 Experts tab.
Two different types of messages in the MT4 Experts tab.

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 has 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.

This picture shows that messages in the Experts tab were printed by two MT4 apps.
This picture shows that messages in the Experts tab were printed by two MT4 apps.

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.

MT4 Experts tab shows on which currency pair or other instrument chart a particular EA was running.
MT4 Experts tab shows on which currency pair or another instrument chart a particular EA was running.

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 its 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.

When Local Trade Copier Client EA prints messages in the Experts tab of the MT4 client terminal, it will add a special chart window ID to help customer identify which EA instance actually printed the message. This helps in case you are running multiple EAs.
When Local Trade Copier Client EA prints messages in the Experts tab of the MT4 client terminal, it will add a special chart window ID to help the customer identify which EA instance actually printed the message. This helps in case you are running multiple EAs.

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 do 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.

Messages from two different Expert Advisors in the Experts tab of the MT4 client terminal. Both apps use unique message ID which helps to identify which EA printed the message.
Messages from two different Expert Advisors in the Experts tab of the MT4 client terminal. Both apps use unique message ID which helps to identify which EA printed the message even if they run on chart windows of the same instrument.

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 a 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 the 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.

Messages from two different Expert Advisors in the Experts tab of the MT4 client terminal.
Messages from two different Expert Advisors in the Experts tab of the MT4 client terminal.

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.

MT4 Experts tab shows error message code 134: Not enough money
MT4 Experts tab shows error message code 134: Not enough money

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 the current account balance. Now, this ToC app will also play a sound alert which lets a 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.

MT4 Expert Advisor prints label with error code on the chart
MT4 Expert Advisor prints label with error code on the chart.

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.

MT4 EA shows error message about an incorrect entry price for BUY STOP pending order.
MT4 EA shows an error message about an incorrect entry price for BUY STOP pending order.

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.

MT4 Journal tab logs error messages received from the broker server
MT4 Journal tab logs error messages received from the broker server.

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 an 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.

Access MT4 Data Folder from the top menu.
Access MT4 Data Folder from the top menu.

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.

MQL4 Experts Log Files in the Data Folder of MT4 platform.
MQL4 Experts Log Files in the Data Folder of MT4 platform.

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.

MT4 Experts messages printed in the log file.
MT4 Experts messages 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“.

Click a right-mouse button anywhere inside the Experts or Journal tab and choose Open to access log files.
Click a right-mouse button anywhere inside the Experts or Journal tab and choose Open to access log files.

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 a few messages can help solve a problem.

View option allows you to filter through Experts log messages. Here’s the window it will open.

MT4 allows you to search for log messages by date and phrase.
MT4 allows you to search for log messages by date and phrase.

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“.

Packing MT4 Log files into a zip archive for easy delivery.
Packing MT4 Log files into a zip archive for easy delivery.

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.

7x MT4 Log files compressed into one ZIP archive.
7x MT4 Log files compressed into one ZIP archive.

To extract .zip archive you need to click the right mouse button on the file and from the pop-up menu choose “Extract All…“.

Extracting Zip archive with compressed and packed MT4 log files.
Extracting Zip archive with compressed and packed MT4 log files.

Conclusion

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.


Rimantas Petrauskas
Rimantas Petrauskas

First I am a father, a husband and then the author of the book “How to Start Your Own Forex Signals Service”. I am also a Forex trader, a programmer, an entrepreneur, and the founder of ea-coder.com Forex blog. I have created two of the most popular trade copiers and other trading tools for MT4 that are already used world wide by hundreds of currency traders.

    12 replies to "How to Understand Confusing MT4 Error Messages (Log Files)"

    • Alex

      Very useful information treated in a professional way.

    • Anan

      Thank you for taking the time to explain very useful information so concisely. Very helpful.

    • Luís

      Hi,
      Thanks for the nice write-up and thorough explanation.
      I´m having an issue with my log file and I was wondering if you could help me…
      – everytime I open, close or modify an order it goes to the log file, so far so good.
      – everytime I open, close or modify an order on my phone (mobile platform), if the pc platform is running, nothing goes to the log file… is there a way to send those orders to the log file?

      Thanks in advance, Regards

      Luís

      • Rimantas Petrauskas

        Luís,

        MT4 write to log file only about the actions and activity that happen on the platform itself. If you do anything remotely then nothing will be written into log files. In your case log files could be written on mobile, but I don’t think MT4 does that on mobile app.

    • klet

      Hi!
      you have really great articles!!
      I have a very specific question about the function of the Metatrader and it’s Log Files. It seems you are an expert on this! Maybe you can help me.

      I’m using an EA which places an order at the beginning of the TF which was set (And if additionaly some other requirements are fulfilled.). So if I set Timeframe M5 the EA will open an order at 0:00, 0:05, 0:10 and so on…
      Normally I trade on M30, to have a reasonable output. Sometimes I shortly put the TF to M1 to trigger an additional order. This was working well all the time.

      But the following happened (See the affected part of the Log File Below):
      At 11:12:39.722 I again set the MT4 to M1 to trigger an order. M1 was initialized also. That is ok.
      Then at 11:12:40.954 I set back the MT4 to M30. There should be M30. But the system initialized M1. I definitely set M30. I checked this also on screenshots…
      So I suppose a malfunction on the brokers execution (or anything like this).
      So the EA opened a Trade every minute which was costly.
      I discussed this with my account manager, but she only answered that it has to be a topic of my EA.
      I don’t think so.

      Here are two specific questions:

      1. Does initializing the TF depend on the specific EA code?
      Because I think it doesn’t. It’s absolutely independent from the EA I use.
      Any EA initializes the TF according to the setting of MT4. So it can’t be a malfunction of the EA?

      2. Is it possible to initialize the same TF twice again? Like it happened from
      11:12:39.722 LionofWS_XXX_V2 EURJPYmicro,M1: initialized
      to
      11:12:40.954 LionofWS_XXX_V2 EURJPYmicro,M1: initialized?
      Because I think that’s not possible. There has to be at least one another TF in between.
      This makes absolutely no sense and I guess there is a malfunction anywhere.

      Thanks for your help!!
      Regards

      2 10:59:51.810 LionofWS_XXX_V2 EURJPYmicro,M30: open #20650485 buy 0.02 EURJPYmicro at 125.939 ok
      2 10:59:51.826 LionofWS_XXX_V2 EURJPYmicro,M30: open #20650499 sell 0.02 EURJPYmicro at 125.909 ok
      2 10:59:52.029 LionofWS_XXX_V2 EURJPYmicro,M30: modify #20650485 buy 0.02 EURJPYmicro at 125.939 sl: 0.000 tp: 126.107 ok
      2 10:59:52.029 LionofWS_XXX_V2 EURJPYmicro,M30: modify #20650499 sell 0.02 EURJPYmicro at 125.909 sl: 0.000 tp: 125.839 ok
      2 10:59:52.372 LionofWS_XXX_V2 EURJPYmicro,M30: modify #20637240 buy 0.02 EURJPYmicro at 126.134 sl: 0.000 tp: 126.107 ok
      0 11:12:39.691 LionofWS_XXX_V2 EURJPYmicro,M30: uninit reason 3
      0 11:12:39.722 LionofWS_XXX_V2 EURJPYmicro,M1: initialized
      2 11:12:39.971 LionofWS_XXX_V2 EURJPYmicro,M1: open #20657495 buy 0.02 EURJPYmicro at 126.057 ok
      2 11:12:40.112 LionofWS_XXX_V2 EURJPYmicro,M1: modify #20657495 buy 0.02 EURJPYmicro at 126.057 sl: 0.000 tp: 126.127 ok
      0 11:12:40.939 LionofWS_XXX_V2 EURJPYmicro,M1: uninit reason 3
      0 11:12:40.954 LionofWS_XXX_V2 EURJPYmicro,M1: initialized
      2 11:21:51.604 LionofWS_XXX_V2 EURJPYmicro,M1: open #20662813 buy 0.02 EURJPYmicro at 126.145 ok
      2 11:21:51.776 LionofWS_XXX_V2 EURJPYmicro,M1: modify #20662813 buy 0.02 EURJPYmicro at 126.145 sl: 0.000 tp: 126.215 ok

    • bob

      Thank you. This is a very well written article. I noticed that there is a long delay from when a new message appears in the MT4 Journal tab compared to when the message is written to the log file. What is causing this? Is there a way that new messages in the MT4 Journal tab are written in the log file in real-time?

      • Rimantas Petrauskas

        Hi Bob. Thanks for your feedback. Glad you like my work.
        As about delay, I am not sure how you change this all the time, but if it’s just once you need to update your log files immediately, then you need to close MT4 terminal. In this case MT4 will update log files on exit immediately.

    • Peter Williams

      Really great article.
      I like the idea of placing an error message on the chart

      I have been trying to read the log files from an EA (my question in FORUM)

      https://www.mql5.com/en/forum/160663#comment_3825624

      Sort of implies I can NOT access these form an EA – is this your understanding

Leave a Reply

Your email address will not be published.