Backtesting Range Bars in Metatrader 4

For MT4 build 574 and higher, this backtesting script names are suffixed with "_b574". Therefor, you should be using RenkoBarsBacktesting_b574 and RenkoBarsBacktestingAlt_b574 scripts with the latest MT4 builds.

The back testing feature for RangeBars is available via RangeBarsBacktesting script, which is part of the RangeBars plug-in for Metatrader4 and is located in the Navigator window’s Scripts branch, once you install the range bars plug-in package.

This backtesting method is mainly designed for backtesting EAs that use completed bars to calculate trading decisions. You should use the “Open prices only” model in MT4′s strategy tester. Scalping EAs and EAs that rely on inter-bar price action should be tested using tick data.

When you double-click the script or drag it onto the selected instrument’s chart you will see the following backtesting options:

The meaning of individual variables are described below:

BactestingRangeBars – This is used to select one or more pip ranges which should be prepared for backtesting using all historical data available in MT4 (on the 1 minute chart). The values should be separated by a comma.

i.e. 3,13,20 = 3 pip range, 13 pip range, 20 pip range.

BacktestingSpreadInTicks – This is used to select the spread value that should be used for backtesting. This value is entered in ticks so if your broker has 5 decimal quotes you should enter 20 for a 2 pip spread.

StartFromBar – This variable defines the amount of historical bars, which will be used to create the range chart for backtesting. It is set by providing the date & time of the first 1M bar used to calculate the first historical range bar for backtesting.

The default value of “1970.01.01 00:00” will result in using all available data on the 1M chart.

BackTestingServerName – This is the name of the virtual MT4 server that will be created and you will need to logon to, in order to use range bars with MT4′s backtester module.

Once you set the values above and press [OK], the script will begin to setup the virtual server for backtesting. Once this procedure is completed you will see the following message:

Now you can logon to the “range” server by choosing Logon from MT4′s File menu. This will display the following pop-up window:

Now, simply enter “range” in the Server field and click [Login]. Your MT4 should now show “No connection” (this is normal).

Next you need to shout down MT4 and reopen it again.
This time you will see the selected range bar symbols ready for backtesting in your Market Watch window:

Now you can open MT4′s strategy tester, select the Expert Advisor you wish to test and select the range bar value to be used by the backtester:

IMPORTANT! - Always choose M5 for the period used for backtesting as the range bar chart is stored on this time frame.

Interested in 99% modeling quality, reliable, tick-by-tick backtesting? Click Here

VN:F [1.9.22_1171]
Rating: 10.0/10 (3 votes cast)

Backtesting Range Bars in Metatrader 4, 10.0 out of 10 based on 3 ratings

Print Friendly
7

Comments

  1. ben  August 31, 2012

    hi i just loaded the backtesting script and kept ‘RenderUsing1MhistoryBars’ at 0, I do not see all bars (4781) of the 1 min chart being used, i only see 93 bars when i change to range sever. what is the point of this?
    when backtesting an ea using only 93 bars it only gets to make one order not able to modify or close. please explain.

    reply
    • admin  September 2, 2012

      This parameter is used to determine the number of 1M bars that will be used to create historical range charts. This number will never be equal to the number of created range bars. In most cases (depending on your range setting), several 1M bars will make up one constant range bar. You should see this video, if you need more range bars in your history.

      reply
  2. ben  August 31, 2012

    do i need to wait for my custom range chart to make more bars? or do i need to add the backtesting script to my custom chart instead of m1 (your pdf does not say)? the main reason i bought you product was for the backtesting as i already have range bars enabled but could not backtest, so backtesting is most important to me!

    reply
  3. ben  August 31, 2012

    I like your feature to make multiple range bar charts from m1 data!

    reply
  4. Noz  January 8, 2013

    Is it possible to create range bars without using/having an offline chart? Or better explained: if there is already an offline chart created based on a fx index (and not based on range, ticks or whatever) and you would like range bars for this fx index, is that possible?

    reply
    • admin  January 9, 2013

      Not sure if I understand you correctly. You would like to create range charts using data that is available on an offline chart?

      reply

Add a Comment

CAPTCHA Image

*