Setting up Node.js & XAMPP/MySQL for MT4

In this short lesson, I will provide the instructions for setting up Node.js  and XAMPP so that you can run apps made with them. This lesson assumes that you are running this in a Windows environment.


  1. Download and install Node.js Windows Installer (.msi) from
    • Download the 32bit version if you have less than 4GB memory or 64bit if you have more.
    • You can install it with the default settings.
    • Now you need to add Node to system path.
      • Hold Win and press Pause (OR Right click on “My computer” > Click “Properties”)
      • Click Advanced System Settings.
      • Click Environment Variables.
      • Append ;C:\Program Files\nodejs\ to the Path variable (If it doesn’t exist, add a new one called Path and add C:\Program Files\nodejs\)
      • Note: C:\Program Files\nodejs\ should be where you installed Node.js
  2. Download and install XAMPP from
    • Make sure you download the version that is for Windows and either PHP versions is fine.
  3. Start the XAMPP control panel and start the Apache and MySQL services.
    • You can install with the default settings. No need to install FileZilla, Mercury and Tomcat
    • Quick note, I noticed that if you have Skype running, then Apache fails to start up. Then just close Skype and start the service again. Then you can start up Skype after all the services are running.
  4. For some of the node modules, Python 2.7 is required. So let’s go ahead and set that up as well.
    • Download the Windows x86 MSI Installer (2.7.3) from
    • Install this with the default settings and location of C:\Python27\
    • Now we need to add Python to your system variables so Node knows where it is.
      • Hold Win and press Pause (OR Right click on “My computer” > Click “Properties”)
      • Click Advanced System Settings.
      • Click Environment Variables.
      • Append ;C:\python27 to the Path variable (If it doesn’t exist, add a new one called Path and add C:\python27)
      • Note: C:\python27 should be where you installed Python
  5. This is an optional step. Certain modules require C/C++ compilers to be installed. So if you need them, then follow the below steps
    • Windows XP/Vista/7:
      • Microsoft Visual Studio C++ 2010 (Express version works well)
      • For 64-bit builds of node and native modules you will also need the Windows 7 64-bit SDK
        • If the install fails, try uninstalling any C++ 2010 x64&x86 Redistributable that you have installed first.
      • If you get errors that the 64-bit compilers are not installed you may also need the compiler update for the Windows SDK 7.1
    • Windows 7/8:
      • Microsoft Visual Studio C++ 2012 for Windows Desktop (Express version works well)

Next steps

  • You may have to install necessary modules for Node.js. To install them. Open up your Windows Command Prompt (Hold WinKey+R > Input “cmd” > Hit Enter) OR (search for cmd in Start Menu search and open the cmd.exe)
  • It’s always best to keep all of your node files in one place. I keep my Node files in C:\Node. So you can create this folder. Then in the windows command prompt, change directory to be in C:\Node. To do so, enter cd c:\Node and hit enter.
  • Now install the needed modules with npm by entering npm install module_name
  • You can get the list of required modules by looking at the Node.js file that you want to run. These modules are listed at the top of the file as var something = require("some_module");
  • To run a node app, simply enter node app_file_name.js
  • You will also need to get familiar with the use of phpMyAdmin in XAMPP in order to setup databases and tables. You can take a look at some of the tutorials in YouTube such as the following

You can now use the Node.js MQL4 bridge to communicate between MT4 and Node.js (

Lastly, if you encounter any issues or have any questions, you can post a comment below or discuss them in the development forum

6 thoughts on “Setting up Node.js & XAMPP/MySQL for MT4”

  1. Hi Saver0,

    I tried to install all things from scratch : Xampp, Nodejs, phython 2.7.x .
    I have successfully create database, and import data from sql file you provided.
    But as i try to run : node fractal_server.js , i got error msg “can not find module underscore”.
    Then i check the Path in windows environment, and it is there :
    …. C:\Node\;C:\Users\Myusername\Appdata\Roaming\npm\; ….

    some one has the same problem :
    it is about the Path, but i have exported the path in windows environment.
    I check “C:\Users\Myusername\AppData\Roaming\npm\node_modules” , i can see some modules
    are installed ; async, moment, mysql, prettyjson, underscore.

    Any body got this error ?


  2. Hi,
    I think i found it. This is what i did :

    a) I add new system variable with the name “NODE_PATH” (without quote)
    the variable value is : “C:\Users\pedma\AppData\Roaming\npm\node_modules” (without quote)

    b) I edited system variable “Path” (without quote)
    and change the values to : “C:\Users\pedma\AppData\Roaming\npm\node_modules” (without quote)

    c) Restart my computer

    d) Start Apache & Mysql via Xammp

    e) open command prompt, and run : “node fractal_server.js”

    I do not know exactly, which one that make it works, and do not worry about it :)

    Hope this will help some one if he find the same problem :)

    note: i do not know how to post an image, but surely i can see blue text 1).. 2)….3) , there are four time each.
    Will see the code deeply and will play with it, and will post here if i found other thing …

    Thanks saver0, great code.

  3. Thanks for reporting this Pedma. I did forget one step, that is to include Node in the System Path. I will update the post to include this step. As for the error “can not find module underscore”, this error means that the Node module underscore wasn’t installed. You need to run npm install underscore but I think you already done that at some point since you got it to work.

  4. In order to get the command line ‘npm install module_name’ commands working (Next Steps from 1st post), I had to get past an ENOENT error # 34 which led me to:

    …where I followed the instructions in the most upvoted comment (not answer):
    5 I’ve just had the strictly the same problem. “npm update -g” fixed it for me. – Rootical V. Apr 2 at 18:31

    …which then allowed me to install the included modules inside fractal_server.js according to the directions.

    So now I have a whole bunch of foreign tools that I have no clue about here on this computer, but apparently it has installed correctly. Hopefully at some point a light will shine how these tools fit together and it will all make sense in terms of the ultimate goal of this project.

    Thanks for your efforts, Saver, I downloaded the project from GitHub. For all this setup, there isn’t that much code. Hopefully the tools will play well with MT4 and I can get something useful out of this by this weekend, and then start getting into the project logic.

  5. I’m now seeing this error when I run:

    C:\Node>node fractal_server.js
    Loading data starttime null euus_fractal_m5 SELECT * FROM euus_fractal_m5 ORDER
    BY datetime ASC

    throw er; // Unhandled ‘error’ event
    Error: listen EADDRINUSE
    at errnoException (net.js:904:11)
    at Server._listen2 (net.js:1042:14)
    at listen (net.js:1064:10)
    at Server.listen (net.js:1138:5)
    at Object. (C:\Node\fractal_server.js:201:5)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)



  6. Hi FXEZ!
    Very happy to hear that you got most of it to work!

    The error that you are seeing is telling you that the port that you are using in the http server is already in use. Try using a different one and make sure that you also set it to be the same in the MT4 indicator so that they are both communicating through the same port.

Leave a Comment

Scroll to Top