DataFeed from Metatrader

written by Ramil Khalikoff, Robert Rundle, Chang Zhi Dai, Alon Awramson, Sergey Lesovikov 

 

Also information from John Perth see here

 

Timing Solution software is able to work with many different data formats. One of popular data sources is client's terminal MetaTrader4; it provides real-time data stream. FOREX traders are especially interested in Currency Loader advisor written for MT4. This advisor has just one purpose: to download quotes from MT4 in real-time format. It can be used by different software programs, including Timing Solution (TS).  

There are two possible ways to download quotes from MetaTrader.

Variant  #1: If you do not need real time streaming and work with daily or hourly chart, you can save the MT4 price chart as *.csv file. In order to do that in MetaTrader,  follow menu "File"->"Save As":

 

 

and type any file name there:

 

 

Timing Solution allows to read this file.

Variant #2: We recommend another approach if you would like to have real time streaming from MetaTrader. A special MetaTrader script allows to download quotes and store them in the file, while Timing Solution reads this file and updates the price history in real time. See below the explanation regarding this subject.

General block diagram of MetaTrader + Timing Solution real time streaming

Settings

4 advisor "Currency Loader" provides historical data for any chosen financial instruments. It downloads the data into "*.csv" files. These files are updated in real time; the frequency of the updates is defined in seconds, as a parameter FrequencyUpdate (by default, its value is 60, i.e. the data are updated every minute). BarsMin parameter shows the minimum amount of price bars available on the diagram before any update is possible. By default it is 100 (i.e. there will be no downloading data if the data file contains less than 100 bars). There is another parameter there, MaxBarsInFile. It defines the maximum amount of price bars that can be loaded into the file. The default value is 20,000. Remember this number; you will have to change it depending on available history data and properties of your computer. For example, if you need the minute data for some instrument that has 800,000 price bar history and your computer is rather old, your computer might be frozen.

Default settings:

LoadM1 = false;
LoadM5 = false;
LoadM15 = false;
LoadM30 = false;
LoadH1 = True;
LoadH4 = True;
LoadD1 = True;
LoadW1 = True;
LoadMN = True;

(Comment by Robert Rundle I only build data files in the timeframes that will be use in TS. There is no point in creating data files (timeframes) that you will not use in your live research. Here I use 1, 5 & 60 minute, & Daily only for TS. And because - I can delete it before I start TS so that data is fresh and seamless just in case there are gaps or overlaps of data. Fault of currency converter . This configuration can then be saved by name, and later these parameters can be applied to a different currency.)




These parameters allow/forbid data downloading. If the parameter is set as True, the data downloading is allowed. If it is set as False, no downloading. You can change the settings any time.

Also, these commands are useful:

AllowInfo - the information re Advisor;
AllowLogFile - recording of the information into log-file.

How to work with Currency Loader for 4

1.       1) Unpack Currency_Loader file (Currency_Loader V2.3.ex4 file) into  \experts folder. The \experts folder is a place on your computer where MetaTrader software stores the experts files.

InIn order to find where \experts directory is located on your computer, make RIGHT mouse click on MetaTrader shortcut, choose the Properties item there:

y    You will get the information box like this:

      

    You see in my computer the MetaTrader program is installed in  c:\Program Files (x86)\GCI MT4\ accordingly the folder for experts is  c:\Program Files (x86)\GCI MT4\experts\

    This is an example of another directory: C  c:\Programs (x 86) \ MetaTrader Finexo\experts\

    This path depends on the version of MetaTrader that is installed on your computer.

       

Troubleshooting #1

We recommend to run MetaTrader as Administrator, this way:

Make a RIGHT mouse click on MetaTrader shortcut and highlight the item "Run as administrator". Otherwise you may face a problem of updating the price history in teal time.

    .   2) Open program MetaTrader, the Currency_Loader should be there.

 

3.       3) Drag Loader to the main MetaTrader screen, and the Currency_loader will appear at the right top corner.

Please make sure that Expert Advisors at the top menu has a green spot as below rather than a red spot to make sure Currency_Loader at the right_up corner comes with a smiling face .

 

4) The program starts downloading the price history and stores these files into \experts\files\Export_History\ folder.

In other words, my version of MetaTrader is installed in c:\Program Files (x86)\GCI MT4\  directory, and the files with updated price history will be located in:

c:\Program Files (x86)\GCI MT4\experts\files\Export_History\  folder.

Troubleshooting #2

Different versions of Currency Loader can store the files in different directories. In our example this folder is used: \experts\files\Export_History\ folder.

It also can be  \experts\files\Export_History\EURUSD\ folder (a special folder for each financial instrument)

or ...\experts\files\history_center\  folder.

It is better to check this directory manually, i.e. run currency loader and check the folders in \experts\files\... folder.

 

Troubleshooting #3

It is possible that MT stores data files with quotes into some hidden folder. There are two ways to solve this issue:

 

#A (suggested by Abhay Agarwal)

Run MT4 in portable mode. In order to do that, make RIGHT mouse click on MT4 shortcut:

 

 

in "Shortcut" tab add /portable in target

 

In this case the data file generated by Currency Loader in c:\Program Files folder like this:

 

 

 #B (suggested by Sergey Lesovikov)

You can delete hidden settings from any folder manually, and it makes them visible from Timing Solution.

 

In order to do that  run File Explorer:

 

 

In "View" tab there set ON "Hidden items". It makes the hidden folders visible in  File Explorer:

 

 

Now you can find the folder where the currency loader stores the data and make this folder visible for public (i.e. for TS).  Make RIGHT mouse click on this folder; in the popup menu highlight "Properties" and set Hidden option there OFF, like this:

 

 

 

In this case the data file generated by Currency Loader in folder

c:\Users\[Username]\AppData\Roaming\MetaQuotes\Terninal\[MT4 number]\MT4\MQL4\Files\Export_history\

 

 

To simplify this procedure you can make visible this folder:

c:\Users\[Username]\AppData\

and  all folders inside this folder will be visible:

 

 

 

Troubleshooting #4

It starts working very soon, you should wait only about a minute after the download. The delay is related to the connection between the terminal and the server and the necessity to update all already opened diagrams. IF YOU USE THE LOADER FOR TOO MANY INSTRUMENTS AT THE SAME TIME, YOUR TERMINAL MIGHT BE FROZEN.
(Comment by Robert Rundle I do a shortcut from desktop to this folder so I can delete it before I start TS so that data is fresh and seamless just in case. RR)

4.       You can also store the price history into any folder. In order to do that:

a.       Press F2 (from Tools at the top menu, then History Centre):

b.      Double click on 30 Minutes (M30) folder AUSUSD (as example). Click Export button to save the file with the price history:

  Description: E:\Screen Shots\Currency_Loader 5.JPG  

You can download this file in Timing Solution in a regular way:

 Description: E:\Screen Shots\Currency_Loader 6.JPG  

6.       
Real Time Streaming"  Timing Solution +
Currency Loader

      You can use the Currency Loader as the source of real time streaming for Timing Solution. To do that:  

6) Run Timing Solution software, download the existing price history and  open Data Feed module clicking button:

 

1.      7) Highlight "From File" item there and click "Data Feed File" button:

8) Choose data feed file from  \experts\files\Export_History\  folder;   in our example it will be 

c:\Program Files (x86)\GCI MT4\experts\files\Export_History\  folder.

 

9) Set the speed of update:

(Comment by Robert Rundle SET INTERVAL EVERY 60 SECONDS, AS TS GETS A LITTLE FREEZY FOR A FEW SECONDS)


 

9) To run real-time regime streaming, click or double-click on this symbol, it must be green:

  

Troubleshooting #5

To control the real time streaming we recommend to click this button:

The program shows the content of real time streaming file. This file should contain information about latest updated price history. If this file does not contain this information please check MetaTrader Currency Loader - something is wrong there.

  

Troubleshooting #6

You should also check the format of this file. Look at this example;

 

To format of this datafeed file is yyyy.mm.dd hh:mm  while the program expects yymmdd format. In order to fix this problem click button and select this file there. Also we recommend to save your work into worksheet to save these changes. 

 

 

How to increase the amount of downloaded price history

 

For data acquisition on currencies I use 4 and I will describe detailed algorithm on example EURUSD60min.
First it is necessary to specify the max amount of lines (as an example 1-2 000 000):
 

 

 
Here  EURUSD 60min chart with maximum 80 000 bars is downloaded.
 
After closing "Option" click  right mouse click and highlight "Refresh":
 
 
 
Alternative variant of updating of data:
 
 
At base updating it is necessary to achieve absence of admissions. Unfortunately, not all currency steams have good history (without holes).

Information from John, Perth

For those people who use MT4 to feed data into TS here is a solution I have found that updates the data into TS when MT4 is

Offline or on the weekends when you want to do your research and the data does not update specifically intraday, here is a

Free software I found that will make sure that when you go to update the charts on the weekend that it will download all the data,

 

  https://fx1.net/mt4ticker.php

 

 

Websites where you can download MataTrader software and open account: