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.
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.
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:
Backtesting Range Bars in Metatrader 4,