Metatrader 4

How big impact has smooth execution of algos on your trading results?

Having all systems online is crucial for every AlgoTrader. Enjoy your life with confidence that your trading robots are working without any obstacle and your VPS is running smoothly. 

In this article we will talk about how big impact has the smooth execution on your trading account. Everything we will explain on examples and live simulations.

First of all, let me explain, which situations could happen?

  • Unexpected shutdown of the platform
  • Unexpected loss of connection to the broker
  • Low margin
  • Disabled Automated trading

Let’s simulate how these situations can impact your trading performance and your balance on your trading account. We will use Quant Analyzer software What-if scenario and Monte Carlo function for this.

What can happen if our platform has experienced unexpected shutdown?

Some trades can be running on the account without managing therefore our algos cannot manage trailing stop, profit target or exit of the trade at certain time (Dangerous holding during weekends.).

Here is result of original strategy

Result of original strategy

If we miss only 1 % of profit trades we can see performance impact

If we miss only 1 % of profit trades we can see performance impact

If we take only every 5 trade we can see performance impact

If we take only every 5 trade we can see performance impact

Comparison of all graphs above: Green: original Purple: every 5 trade Yellow: 1 % missed trades

Comparison of all graphs above: Green: original Purple: every 5 trade Yellow: 1 % missed trades

We can see that impact of smooth execution of trades is very important. Return Drawdown ratio has dramaticly dropped from 9 to 3.

Monte Carlo Analysis – 10 simulations of Random Skip trades with 5 % of probability.

During these unexpected moments it is crucial to be informed about these events ASAP. Therefore, we are offering professional solution which can immediately notify you via email or SMS when something unexpected happen. You will have time to solve the issue and prevent loses. This is what our monitoring platform can do. Try our monitoring platform and have all your algos monitored.

Check for FREE how can QuantMonitoring help you

Receive 30 days free trial period + access to interesting know-how

How to install Metatrader 4 under Linux

n today’s tutorial, I would like to show how to install Metatrader 4 or Metatrader 5 for Debian Linux distribution. The license fees for Windows Server are more than high and this can be the way how to save money for the VPS or physical server operating system.

Considering that some unexpected installation issues may occur during the installation or when running the Metatrader 4/5 process alone, this article is more considered for advanced users.

So let´s start. What are we going to need?

Now let’s start with the Wine installation:

 1. In order to avoid writing sudo with every command, switch to root user with the command and insert password.

su –

password:

2. First we allow the installation of the 32-bit packages

dpkg –add-architecture i386

3. Add a key for wine repository:

wget -nc https://dl.winehq.org/wine-builds/Release.key
apt-key add Release.key

4. Add this repository line to the file /etc/apt/source.list file

deb https://dl.winehq.org/wine-builds/debian/ jessie main

5. Install package support from https using the command:

apt-get install apt-transport-https

6. Then update the list of packages from the repository using the run command:

apt-get update

7. Then install Wine using the command:

apt-get install –install-recommends winehq-stable

8. After Wine is installed, it is necessary to configure the wine and run it with the command:

winecfg

after running this command, the pop up window will appear with the message that there are missing additional packages, that has to be installed, so click to download and install them.

9. When you start a winecfg, you need to set the emulation for Windows 7 (check the screen bellow):

We can now install Metatrader 4

1. Run the Metatrader 4 installation package and change the installation folder

2. Run Metatrader 4 and enter your login details

If we want to install MT5, we will use the same procedure. Metatrader 4 runs on Linux directly in portable mode, but the MT4 data are in a different location than in Windows.

!!! ATTENTION !!! Metatrader 4 data with strategies and indicators can be found in the following folder:

/home/USER_NAME/.wine/drive_c/MT4/MT41/MQL4/

Note at the end

I wanted to know how the MT4 on Linux is demanding CPU vise, so I made an experiment. I ran the same amount of MT4 instances on Linux and Windows. My measurements were clear, the Windows emulation is worth some HW costs. On Linux, the CPU usage was roughly twice as on Windows.

The most common errors in Metatrader 4 and how to solve them

Metatrader is the most widely spread platform and it may happen that it will report us an error during our trading. In today’s article, we will have a look at the list of most common errors and we will describe how to deal with them.

 I put the strategy into MT4 but nothing happens. Is anything wrong? What should I do?

There may not be anything wrong. Sometimes it takes time until the strategy starts trading. Check the MT4 log (the “log” tab in the terminal) and if there is no error, the smiley laughs, then just wait until the strategy starts trading.

 I found the Trade is Disabled error in the log. What should I do?

This is the most common error with XTB broker and Purple Trading and it means that trading is forbidden.

XTB Broker Solution – Trading is forbidden on a standard account, and you must switch to Standard +.

Purple Trading Broker Solution – Probably, you have put the strategies in the wrong chart. You need to add a strategy to the right chart. If you use a STP account, you need to put strategies in a graph without the _ecn suffix if you have an ECN account, you need to use symbols with the _ecn suffix.

What should I do if Metatrader 4 is disconnected from the broker´s server?

Here are two options. The first option is to restart MT4. The second option is to click on the account with the right mouse button and click on sign in. If it still does not help, contact the broker if there is a problem on his side.

Error Indicator is missing is shown it the metatrader. What should I do?

Make sure you have a copied StrategyQuant indicators. Indicators can be found in C: \ StrategyQuant \ custom_indicators \ mt4 \ indicators. Copy these indicators into the MT4 MQL4 \ Indicators folder

In the Metatrader 4 log appeared error the trade context is busy. What should I do?

Most often, this error occurs when a lot of strategies (10 or more) are in one MT4 and MT4 cannot handle so many commands at a time. In this case, I recommend splitting strategies into multiple MT4s – simply said, for example install 10x MT4 and then logging 10 times under the same account. The recommended maximum strategy for one MT4 is 10. This is the tested number of strategies in which the program runs steadily and without problems.

Errors in Metatrader

Here is the list of errors and messages in MT4. If you would meet one of them and did not know how to proceed, please contact us.

ErrorError IDDescription
ERR_NO_ERROR0No error returned.
ERR_NO_RESULT1No error returned, but the result is unknown.
ERR_COMMON_ERROR2Common error.
ERR_INVALID_TRADE_PARAMETERS3Invalid trade parameters.
ERR_SERVER_BUSY4Trade server is busy.
ERR_OLD_VERSION5Old version of the client terminal.
ERR_NO_CONNECTION6No connection with trade server.
ERR_NOT_ENOUGH_RIGHTS7Not enough rights.
ERR_TOO_FREQUENT_REQUESTS8Too frequent requests.
ERR_MALFUNCTIONAL_TRADE9Malfunctional trade operation.
ERR_ACCOUNT_DISABLED64Account disabled.
ERR_INVALID_ACCOUNT65Invalid account.
ERR_TRADE_TIMEOUT128Trade timeout.
ERR_INVALID_PRICE129Invalid price.
ERR_INVALID_STOPS130Invalid stops.
ERR_INVALID_TRADE_VOLUME131Invalid trade volume.
ERR_MARKET_CLOSED132Market is closed.
ERR_TRADE_DISABLED133Trade is disabled.
ERR_NOT_ENOUGH_MONEY134Not enough money.
ERR_PRICE_CHANGED135Price changed.
ERR_OFF_QUOTES136Off quotes.
ERR_BROKER_BUSY137Broker is busy.
ERR_REQUOTE138Requote.
ERR_ORDER_LOCKED139Order is locked.
ERR_LONG_POSITIONS_ONLY_ALLOWED140Long positions only allowed.
ERR_TOO_MANY_REQUESTS141Too many requests.
ERR_TRADE_MODIFY_DENIED145Modification denied because an order is too close to market.
ERR_TRADE_CONTEXT_BUSY146Trade context is busy.
ERR_TRADE_EXPIRATION_DENIED147Expirations are denied by broker.
ERR_TRADE_TOO_MANY_ORDERS148The amount of opened and pending orders has reached the limit set by a broker.

How to run the Metatrader in portable mode and what it is good for?

What is the portable version of Metatrader 4? What benefits does it bring? Learn all this is in our today’s article.

What is the portable version of Metatrader 4?

Portable is a portable program that can be booted from a portable device such as a flash drive, memory card or other disk location different from program files. The portable program is typically designed to store its configuration and user data in its own location and not on the system disk in the user’s data folder. In newer Windows, it can be usually found in:

“C \ Users \ ‘username’ \ appdata”, which is quite uncomfortable to work with. If we choose a portable version, we will have indicators, strategies, etc. in a folder such as C: \ mt4 \ MQL, which is more convenient.

What brings the portable version of Metatrader 4?

For me, it personally brings better overview and better handling of the MT4 platform. For example, I do not have to install MT4 every time, I can just copy the MT4 folder and use it for another account. Another advantage is greater simplicity when backing up the MT4 configuration or a possible shifting to another VPS – How to run Metatrader 4 on VPS.

Another advantage is that when I go for a holiday, I can have a MT4 backup on flash disk and if I there is a problem with my mobile or laptop, I can connect from any computer without installing MT4.

How to set up a portable Metatrader 4?

It’s fairly easy. In the shortcut icon/desktop icon just add / portable, as you can see bellow:

  • Right click on the mt4 icon
  • Select properties
  • Add to the target / portable

After this change, save the changes and then run MT4 as a portable from the directory where we you run it. I recommend to do this change right after installing MT4, if you modify an already running MT4, you may need to copy the original user data from the MT4 app data directory, which I do not recommend because you could forget something and then wonder that you have lost your indicator etc.

Tips for reducing Metatrader 4 CPU usage on VPS

Metatrader can take a lot of CPU resources because it does some extra operations that we do not need in order to run our automated strategies on VPS and this, of course, increases heavily the VPS usage. It renders charts, downloads unnecessarily long data, unused symbols, plays notifications and other features that are not necessary for running automated trading strategies. In today’s article, we’ll show you how to disable these features and reduce the CPU usage on VPS. Thanks to optimizations, we can multiply the number of running instances of Metatrader 4 to maximize the VPS potential. Regarding the VPS usage itself, I recommend tracking it with the Task Manager.

So, let’s start with the tips:

Minimize the MT4 application on the Windows bar

Minimizing the windows in MT4 – From practice, it turned out that at the moment when Metarader 4 renders charts, CPU usage is increased rapidly.

Hide all unnecessary symbols as shown in the picture – so the platform will not download unnecessary data for other symbols

Hiding the terminal with open commands – Metatrader does not have to render anything and the usage is smaller

Disabling news displayed in the platform,  please see the picture- this setting can be found in tools -> options

Disabling audio alerts, please see the picture – this setting can be found in tools -> options

Minimalizing the number of candles in the chart, see the image – here I recommend using a minimum value of 5000, when you put less candles, some strategies may not work accordingly.

Disabling the automatic movement of the candles in the chart, see the picture

After these optimizations, the Metatrader 4 platform may look like this.

As you can see it is not complicated and it is definitely worth running optimized mt4, so you can run as many MT4 platforms as possible on your VPS. You can save a lot of money 😉

Get access to the #1 Dashboard for AlgoTraders

Register for FREE and get access to:

By registering you agree with our Terms and Conditions