Shared MQL4 folder for multiple MT4 instances

Modified on Fri, 17 Mar 2017 at 02:25 PM

MT4 uses a single CPU core when backtesting so having several instances running backtests or optimizations in parallel lets you take advantage of modern CPUs that have multiple cores.


This article will help you set up several copies of Metatrader 4 which share a single MQL4 folder so that whenever you install or update an EA it is automatically done in all the MT4 terminals that you are using for your backtests.


Please note that this procedure requires a certain degree of familiarity with Windows and the command line. If you do not possess that, I would not recommend attempting it. It's important to note that no support is provided for this article seeing that it's a Windows trick that is completely unrelated to the Tick Data Suite.


Procedure


Let's assume you have a CPU with 8 virtual cores and you would like to have 8 MT4 instances running at the same time. You could do this by starting them from the same folder but I strongly recommend against that because it can lead to all sorts of problems.


As such, to accomplish such a setup you should go through the following series of steps:

  1. Make 8 copies of your MT4 installation folder. You can place them wherever you wish, for instance you could make an MT4 folder on your desktop and place all of them inside it.
  2. Create shortcuts to the terminal.exe file for each of the 8 instances on your desktop. Name them MT4 1, MT4 2, ..., MT4 8. You can of course choose a name other than MT4 but I would advise keeping the number suffix to make it easier to identify the instances and progress through the guide.
  3. Start all 8 instances and login to an MT4 account in each of them. You can use the same account in all of them, in fact I would even recommend that.
    Note: If you wish to have the most exact conditions that resemble your live account, I would advise logging in to your live account using your investor password - the reason for using the investor password being that you can't accidentally place live trades from an MT4 instance that you are using for backtesting.
  4. Close all 8 instances.
  5. Head to https://technet.microsoft.com/en-us/sysinternals/bb896768.aspx and download Junction.
  6. Unpack junction.exe to a folder that is in your system path, I would recommend putting it in C:\Windows\System32\
  7. Run the MT4 1 terminal.
  8. Head to File -> Open Data Folder. Browse to the MQL4 folder, click the address bar to select the path location, copy it then run Notepad and paste it in there; write MT4 #1 above it to be able to easily identify it. The path should be something like C:\Users\Username\AppData\Roaming\MetaQuotes\Terminal\50CA3DFB510CC5A8F28B48D1BF2A5702\MQL4 - the elements in bold text will be different for everyone.
  9. Close the MT4 1 terminal.
  10. Run the MT4 2 terminal.
  11. Just like you did during step #8, head to File -> Open Data Folder, browse to the MQL4 folder, copy/paste its location to your Notepad document and write MT4 #2 above it. The path should be similar to the one obtained in step #8 but with a different second element (the hexadecimal string).
  12. Close the MT4 2 terminal.
  13. Run a command prompt.
  14. Type:
    rd /s /q "<MT4 #2 MQL4 location from step #11>"
    Naturally, you will have to replace the text between the <> tags with the text you obtained in step #11 and pasted in your temporary text file. Do not also paste the MT4 #1 text that you wrote next to it, just the path.
    The enclosing quotes are mandatory if you have spaces in your username.
  15. Type:
    junction "<MT4 #2 MQL4 location from step #11>" "<MT4 #1 MQL4 location from step #8>"
    As in step #14, replace the texts between the <> tags with the texts obtained in steps #11 respectively #8. Similarly, the enclosing quotes are mandatory if you have spaces in your username.
  16. Done - you've linked the MQL4 folder of your MT4 2 instance to your MQL4 folder of your MT4 1 instance. You can now repeat steps 10-15 for the other MT4 terminals, substituting MT4 2 in the text with MT4 3 - MT4 8.