Blog

Backtesting EAs on RangeBars, Renko, Median Renko & PointO charts using tick data on MT4

This page is obsolete and no longer maintained. Please browse the blog article for information regarding backtesting on different custom charts.

This is a step-by-step guide to help you with testing EAs on various price based charts using tick data. The backtests will be performed with 99% modeling quality.

You will need the following software components (links provided in the list below):

Step 1 – Downloading tick data needed to perform the backtest

There are several ways to acquire tick data for the period we wish to perform the backtest on. I use the Tick Data Downloader program, which is simple to use.

Once you install and start the program you’ll see the following window:

The grid is used to select individual symbols with corresponding date span selectors for downloading data. Use this grid to select the symbol(s) needed for backtesting and the date range desired for the backtest.

For this guide, I will only focus on one symbol ( EURUSD, the period from  10.05.2015 to 10.11.2015 ):

Once EURUSD is selected plus the “Download from – to” field is set to the desired date span, you can begin downloading tick data by pressing the “Start download” button. The download process will begin and it will take some time to complete. When the download, which will be indicated in the Status column, you’ll need to click the “Export data” button.

When all tick data is exported to a CSV file, you need to copy the file from the application’s data output directory to your Metatrader’s <data-folder>/MQL4/files folder.

Please note the name of the exported CSV file as you will need to enter this name into the “CsvFile” input of the CSV2FXT script.

At this point, you can close the Tick Data Downloader program and move on to step 2.

Step 2 – generating your .FXT and .HST files for time-based charts

At this point, you already acquired tick data from an external source, generated a valid CSV file containing tick data for the selected symbol and placed that file in your data folder’s MQL4/files sub-folder.

Next, you need to start your Metatrader terminal (don’t start TDS at this point, as the script will not run properly under TDS) and ensure that it is connected to your broker’s server (live or demo).

You will also need the appropriate CSV2FXT script modifications* in your experts/scripts folder of MT4. They will be accessible from MT4’s Navigator window under Scripts:

Each modification is used for generating a different price based chart format:

CSV2FXT_medianrenko_mod_b574 is used to generate a synchronized .FXT & .HST file pair for a Median Renko chart of a symbol you will be backtesting

CSV2FXT_pointo_mod is used_b574 to generate a synchronized .FXT & .HST file pair for a PointO chart of a symbol you will be backtesting

CSV2FXT_rangebars_mod is used_b574 to generate a synchronized .FXT & .HST file pair for a RangeBar chart of a symbol you will be backtesting

CSV2FXT_renko_mod_b574 is used to generate a synchronized .FXT & .HST file pair for a Renko chart of a symbol you will be backtesting

CSV2FXT_tickchart_mod_b574 is used to generate a synchronized .FXT & .HST file pair for a Tick chart of a symbol you will be backtesting

CSV2FXT_*_mod_b574 scripts are compatible with MT4 builds 574 or higher. They have been successfully tested with TDS

*) These are optional premium addons to the charting plug-ins, which are only available in the PRO version of the plug-ins available on this website.

Please contact us if you already own our plug-in(s), but you don’t have the corresponding CSV2FXT file and you would like to purchase it without having to re-order the plug-in.

Since we will be backtesting the EURUSD pair we need to open a 1M chart of EURUSD and drag the selected CSV2FXT script modification onto that chart. This will display a settings window for the selected chart type:

  • Median Renko Chart

    The top two settings are used to define the Median Renko bar size (how many pips in size will each candle body measure) and the RetracementFactor.

    The RetracementFactor value influences the retracement level for each bar. Standard
    median renko bars use a retracement level of 50% (RetracementFactor = 0.5). This value
    is user-defined and can be set from 0.01 (1%) to 0.99 (99%).

    The remaining values in the file are described on Birt’s EA Review page: http://eareview.net/tick-data/convert-tick-data

  • PointO Chart

    The barSize setting defines the range size of each candle’s body (value entered in regular pips)

    The remaining values in the file are described on Birt’s EA Review page: http://eareview.net/tick-data/convert-tick-data

  • RangeBars Chart

    rangebars_tds_sq

    The barSize setting defines the range size of each bar (value entered in regular pips)

    The StrategyQuantExport setting (true/false) enables data export for use with StrategyQuant software

    The remaining values in the file are described on Birt’s EA Review page: http://eareview.net/tick-data/convert-tick-data

  • Renko Chart

    renko_tds_sq

    barSize defines the size of each bar’s body (value entered in regular pips)

    barType define the type of chart as described in the Renko Plug-in. (values of 1 & 2 are currently supported)

    useFirstRenkoPipOffset & FirstRenkoPipOffset values are described in the user manual

    The StrategyQuantExport setting (true/false) enables data export for use with StrategyQuant software

    The remaining values in the file are described on Birt’s EA Review page: http://eareview.net/tick-data/convert-tick-data

  • Tick Chart

    tickchart_csv2fxt

    TicksPerBar defines the desired number of ticks needed for a new bar to form

    The StrategyQuantExport setting (true/false) enables data export for use with StrategyQuant software

    The remaining values in the file are described on Birt’s EA Review page: http://eareview.net/tick-data/convert-tick-data

After the settings are defined you need to press [OK] and the preparation of EURUSD.FXT & EURUSD.HST files will begin. The script will update the percentage of completion on the 1M chart:

This will take some time to complete and once done, the following modal windows will pop up:

The choices you have are [YES] and [NO].

You should choose Yes if you will be backtesting under the same MT4 terminal.

If you choose No, you will need to manually copy the EURUSD.FXT file to your selected Metatrader’s tester\history folder and the EURUSD.HST file into your selected Metatrader’s history\ServerName folder. This may be necessary if the files are very large. However, for this guide, I will assume that you’ve pressed Yes and the generated files have been copied into the correct folders.

You’ll now need to shout down MT4 and move to the next step.

Step 3 – Preparing your EA for proper testing on price based charts

As of version 2.20 of MedianRenko, Renko, and PointO as well as version 3.20 of RangeBars this step is no longer required – you can skip down to step 4.

You’ll need to include 2 lines of code in your EA so that it can be to be properly backtested using tick data & price based charts (especially MedianRenko).

To demonstrate the process, I will use the MACD Sample EA, which is included with every MT4 distribution in an uncompiled MQL format:

You need to open the EA file in the MQL editor. This can be done by right-clicking on the EA name (MACD Sample) and choosing Modify from the popup. This is how the code will look like in the original form:

Now we need to include an MQL code snippet, which is distributed and automatically installed with the plug-ins. This is done by adding a #include <CustomChartingBacktest.mqh> statement at the beginning of the EA code:

plus adding the if(skipFirstTickOnBacktest()) return; function call at the top of the OnTick(void) function:

This will ensure that you EA backtests properly on price based charts (especially on Median Renko charts).

You don’t need to remove this code from your EA for live or demo operation since the function will only work when the EA is being backtested.

Once your EA is modified in the same way as the presented sample EA, you need to compile the EA by pressing the Compile button, which is located on the MQL editor’s toolbar and move to the next step if the EA complied successfully.

Step4 – Backtesting you EA using Price based charts & Tick Data

You’ll need the Tick Data Suite application (TDS) for this step – if you don’t have it yet, you can download a 7-day trial version and give it a try.

Make sure that the application is properly installed and configured for use with you MT4. First, you’ll need to close your MT4 and now simply run the tds.exe program, which should be located in your MT4 folder:

Your MT4 terminal will be loaded and patched at runtime by the TDS application, which will ensure proper operation when the backtest is performed.

Backtesting can now be performed by bringing up the strategy tester window (Ctrl-R) in Metatrader and setting the following parameters:

Expert Advisor – set this to the name of your EA, which has been modified in the previous step,

Symbol – set this to EURUSD (as we’ve downloaded and prepared the tick data for this symbol)

Period – set this to M1 (all backtesting using price based charts will be performed on the M1 period)

Model – set this to Every Tick

Visual mode – check this box, if you wish to view the chart as your EA is being backtested

The backtest will begin once you press [Start]

Step 5 – Analyze and perfect your trading strategy or robot

When you come up with an interesting strategy or find a promising robot that proves to be good in the backtests, it is time to take your analysis a step further. There is an excellent tool for this, which is called Quant Analyzer and is made by the same company that gave you the Tick Data Downloader.

Click to try out the Quant Analyzer

Top
27

Comments

  1. Daniel Vieira Costa  May 6, 2013

    I’ve bought the renko plugin, but I cannot run backtesting with 99% model quality

    reply
    • admin  September 23, 2013

      You need the PRO package in order to generate data for backtesting with 99% modeling quality.

      reply
  2. Offs  February 11, 2014

    Hi.

    Last Sunday I bought the renko “PRO Plug-in with Modified CSV2FXT script for Tick Data Backtesting”.

    Everything is ok with that, it generates the .hst and .fxt files correctly, tried it with a trial version of TSD and perfect! But I have bought a TSD license, and now my mt4 is updated to build 604, and when I try to test it gives me an error.

    I tried to generate .fxt and .hst files again but the problem persists. Any solution? Maybe is an old version of “PRO Plug-in with Modified CSV2FXT script for Tick Data Backtesting”? And if exist a new version, where can I download it?

    reply
    • admin  February 14, 2014

      The plug-in files and backtesting instructions on the website have been updated. You’ll need to run “updateRenkoPlugin.bat” to get the latest updates on your computer.
      Please note that you’ll also need to locate your MT4 data folder and copy the files from MQL4 folder located inside your MT4 installation folder to your data folder.
      You can read more abut this here:

      http://www.az-invest.eu/metatrader-4-build-574-where-are-my-indicator-ea-files

      reply
  3. Didier  July 2, 2014

    Hi,

    Is the system working for MT4 625+build? I can’t seem able to run the ea on my mt4 build
    (build 646, 30 April 2014) which seems to be the latest mt4 build.
    cheers.

    reply
    • admin  July 3, 2014

      Yes. The latest version 2.05.03 is compatible with the latest MT4 builds.

      reply
  4. FX Trader  May 29, 2015

    Could I not use TickStory lite for tick data (which also converts tick data to FXT files) instead of StrategyQuant and then use the Tick Data Suite to do the actual backtest? If so, this would save over $1400 so I could then backtest Range Bars. Thank you.

    reply
    • admin  May 31, 2015

      Yes, you can use TickStory to download the data and use TDS as your launcher for Metatrader. Please follow the instructions located here up to the point where you use TickStory as the launcher – you can use TDS for this step.

      reply
  5. Marian  August 4, 2015

    When I am trying to put the script on 1 min chart it tells me that it cannot open the csv. file. Can you advise me? I have CSV2FXT_*_mod_b574 script.

    reply
    • admin  August 7, 2015

      By default, the CSV2FXT_*_mod_b574 script will look for a CSV file named as the chart you are running the scrip of. For example, if you are placing the script on EURUSD, it will look for a file named EURUSD.CSV. Therefor, if your CSV file is named differently, you need to provide the full name of this file (including the “.csv” extension) in the script’s settings – this is the “CSV filename” variable in the script’s Inputs.

      reply
  6. Brian  August 7, 2015

    I brought A-Z renkos and I love them but every few days they stop working and it says Trial period over. This is extremely annoying because you have to delete and re download them. Right now I have done that and I still cant use my renkos. This problem needs to be fixed ASAP

    reply
    • admin  August 7, 2015

      You need to make sure that you’ve placed your license file in metatrader’s installation folder as instructed in the e-mail received after purchasing the plug-in. Additionally, please make sure that you have not changed the name of this file. You can always contact support and send a screenshot of your metatrader’s installation folder’s contents so we can verify if everything has been setup correctly. There is absolutely NO need to delete and reinstall the plug-in.

      reply
  7. Manuel  October 8, 2015

    Hello. When I add the script into my chart. it says Can`t open input file GBPUSD.csv.
    But my file is exactly named like this. has it something to do that my file is an “microsoft excel comma separated values file”?

    reply
    • Manuel  October 8, 2015

      ok I found the problem. but I have a new one. since I added
      #include

      void OnTick()
      (
      if(skipFirstTickOnBacktest()) return;

      i have an error called “unexpechted end of program” and “unbalanved parentheses”

      reply
      • admin  October 8, 2015

        Please send your OnTick() function body to support desk.

        reply
      • Rachid Abdi  July 29, 2018

        hello, can you explain what was the problem solution i have the same problem please

        reply
        • admin  July 29, 2018

          Hi, Please explain which problem you are referring to.

          reply
    • admin  October 8, 2015

      The CSV file needs to be placed in the Files folder, which is found in your {metatrader’s data folder}/MQL4/Files. You can access your {metatrader’s data folder} from the File/Open Data Folder menu item in MT4.

      reply
      • Manuel  October 8, 2015

        ok thanks i made everything work now. but for some reason my macd backtest indicator does not show the same results as as the live chart at the same date and time. what is problem here?

        reply
        • admin  October 9, 2015

          Are you using the same data feed and spread? Did you include the code snippet featured in this article? Please send your backtest and forward test results to support so we can analyze and help.

          reply
  8. Jay  July 16, 2016

    Hello

    if I use Renko & Tick Chart plug-in Pro Version with Tick Data Suite do I still need to update my EA code? what if I don’t have access to EA code?

    Thanks

    reply
    • admin  July 17, 2016

      Hi. Code modification was only needed for median renko charts – it is not required for standard renko charts. Even for medain renko, this is already fixed in version 2.12, and MQL modification is no longer needed.

      reply
      • Jay  July 17, 2016

        Thanks, trading community got great products.

        reply
  9. Carlos  January 5, 2017

    After installing TDS, it does not appear in the MT4 folder. What am I doing wrong?
    Thanks!

    reply
    • admin  January 17, 2017

      TDS (Tick Data Suite) is a 3rd party application. Version 1.x will not be visible in your MT4. Version 2.x will be integrated with your MT4. Please open a support ticket with out helpdesk and let us know what you are trying to do so we can assist you further.

      reply
  10. Stephen Canner  August 9, 2018

    I have the rangebars plugin (pro version) and frequently use the StrategyQuant export feature in the CSV2FXT script to generate historical range bar data in a CSV format for analysis in other programs.

    Now I’m interested in the Point O plugin, but the screenshot on this page doesn’t show the StrategyQuant export as an option. Maybe it is below the bottom of the screenshot? Is CSV (“StrategyQuant” export of Point O bar data an option?

    reply
    • admin  August 9, 2018

      Hi, You can generate the input file for StrategyQuant for Point O bars using the Ultimate Renko PRO plug-in. The plug-in is able to generate Point O bars. Input parameters are shown on the product page.

      reply

Add a Comment