Range bar strategies step-by-step

In this article I’ll explain the step-by-step process of building a strategy for range or renko charts on MetaTrader4. The example below will use range bars, but the same process can be applied also to renko charts.

What are Range or Renko charts?

They are alternative charts that don’t display data in blocks grouped by time (5 minutes, 15 minutes, 1 hour) but by other criterion.
For Range bar, one candle on the chart represents given range, for example 10 pips. So every time market moves by another 10 pips a new candle is drawn.

Image: Range chart – every bar has the same size (range from high to low)

NinjaTrader platform has build-in support for these chart types, so the only thing you need to do to use these charts in SQ is to export the chart data as same as for any other chart type.

MetaTrader4 platform doesn’t natively support Range or Renko charts, in order to display and use them you need third-party plugin. Very affordable provider of Range/Renko plugins for MT4 that we tested and can recommend is AZ-INVEST.EU

What you’ll need

The process

  1. Obtaining the data
  2. Installing and using the AZ-INVEST Range bars plugin
  3. Generating Range chart data using CSV2FXT script
  4. Importing the data file to StrategyQuant
  5. Strategy building process
  6. Testing your new strategy in MetaTrader
  7. Trading your new strategy in MetaTrader

Obtaining the data

You should use high quality (preferably tick) data to compute accurate range or renko charts. You can use our Tick Data Downloader to download high quality tick data for free.
Just download the data for your selected symbol and export it as tick data to CSV file. In this example I’ll use GBPUSD data.

Image: Downloading and exporting tick data

Installing and using the AZ-INVEST Range bars plugin

MetaTrader4 doesn’t natively support Range / Renko bars, you need to use external plugin that will enable this functionality. Purchasing and installing this plugin is beyond the scope of this article, it is a simple process.
AZ-INVEST plugins do have their own documentation and standard installer that will lead you through the setup.

Generating Range chart data using CSV2FXT script

With the Pro version of the Range bars plugin you’ll get a set of special CSV2FXT scripts that should be used to generate data files that will be needed for backtest.
If you properly installed the Range bars plugin you should see these scripts in your MetaTrader.

  1. Start your MetaTrader terminal.
    If you have Tick Data Suite installed DON’T start TDS at this point, as the script will not run properly under TDS.
  2. Open your MT4 Data folder. To find out what is your data folder, open MT4, head to File -> Open Data Folder, which will open an explorer window with your MT4 data folder (typically looks likeC:Users[username]AppDataRoamingMetaQuotesTerminal[32_character_hex_string]).
  3. Copy the CSV file exported from Tick Data Downloader to folder MQL/Files in your MT4 data folder.

  4. Open the chart for GBPUSD, 1 Minute. You should always use 1 Minute the chart of the symbol you want to work with. Then go to Scripts and start CSV2FXT_rangebars_mod script.There are 3 important parameters:
    • barSize – for Range bars we have to choose the size of bars in chart
    • StrategyQuantExport=true – this will ensure that the conversion script will generate also data file for StrategyQuant
    • Spread – it is best to use fixed spread, as StrategyQuant cannot use variable spread on Range / Renko charts

Then click on OK. This script will generate .HST and .FXT files necessary for testing in MetaTrader as well as data file for StrategyQuant.

This data conversion will take some time and you’ll see its progress on the chart.

When it is finished it will show dialog asking you if it can copy the new HST and FXT files to the appropriate folders. You can clickYes

Importing the data file to StrategyQuant

The next step is importing the generated range data file to StrategyQuant so it can be used to backtest strategies. If you used StrategyQuantExport=true the script generated new data file containing range chart data in your MQL4/Files folder.

We’ll import this file to StrategyQuant.
Open StrategyQuant, go to Data Manager and create a new symbol GBPUSD_range10:

Now select the new symbol and import the file GBPUSD_10pip_rangebars.csv generated in previous step.

You will see the new data with Timeframe type Intraday.

That’s virtually all! Now you can work with the new symbol in StrategyQuant as same as with any other data and generate new strategies for it.

Strategy Building Process

Building strategies for Range or Renko data is as sam eas building them for any other standard timeframe. You can of course use In-Sample and Out-of-Sample periods, robustness tests, optimizations, etc.

For more information on complete strategy building process please refer to this article.

Testing your new strategy in MetaTrader

Let’s say we generated some nice strategy in StrategyQuant and we want to test it in MetaTrader. In this example we’ll use Strategy 0.2232 below.

To test your range strategy EA in MetaTrader you need Tick Data Suite. Start your MT4 using TDS. Then go to Tools -> MetaQuotes Language Editor and create New Expert Advisor with name Strategy 0.2232.

Copy & paste the strategy EA from StrategyQuant to MetaQuotes Editor and compile the strategy.

Then open Strategy Tester in MT4 and choose GBPUSD symbol on 1 Minute timeframe. If you didn’t do any change, you still have the .FXT and .HST files generated by CSV2FXT scripts in their place and they will be used in backtest.
Select your strategy and click on Start to start the backtest.

When the test is finished you can check the chart, you’ll see that the results are as same as in StrategyQuant.

Trading your new strategy in MetaTrader

Trading the strategy in MT4 requires opening a range chart. Go to the GBPUSD, M1 chart and then find RangeBarChart indicator in Navigator -> Custom Indicators. Apply this indicator to the chart with the correct setting – in our case we used pip Range = 10 before.

Once you’ll do this you’ll see the following comment below your chart:

Now you need to open the generated offline chart – GBPUSD,M2 (as presented in the displayed comment) to access the LIVE RangeBars chart:
Open GBPUSD, M2 offline chart for 10.0 pip RangeBars.
To do this go to the File menu in your MT4 terminal and click on the Open Offline menu item:

The “offline” chart will start “ticking” when new quotes are received by MT4 and new bars will be created as they are formed.
Please note that every time the plug-in is attached (or MT4 terminal is restarted) it will recalculate all historical data so keep this in mind when you set the “RenderUsing1MhistoryBars” to 0 (all ofhistory).

Despite its name this is live range chart and you can normally add EA to it:

This EA will then normally trade on this range chart on demo or real account.

Notify of
Newest Most Voted
Inline Feedbacks
View all comments
Florian Finke
Florian Finke
19. 1. 2020 10:43 am

Hello, its the same for Meta Trader 5? Thanks

Florian Finke
Florian Finke
19. 1. 2020 11:25 am

Hello, can i also use this? I need the Median Renko, that would be very nice. Thanks

Reply to  Florian Finke
21. 1. 2020 8:51 pm

You should be able to work with this the same way like with the Range bars plugin mentioned in the article. For MT5 you can check this link https://www.mql5.com/en/market/product/16762#!tab=tab_p_overview

Martin Keberle
Martin Keberle
27. 7. 2023 9:52 pm

Hello, just wanted to ask if the Range Bars Charting from MQL5
is still the only way how to apply Renko from MT5 to SQ ?

Reply to  Martin Keberle
30. 7. 2023 11:53 am

if you manage to export range/renko data from MT5 you can import SQX without any issue. Beware you import raw OHLC data for final bars so SQX cannot look into the bar (intra-bar). It knows only 4 prices

Reply to  tomas262
19. 11. 2023 5:20 am

Hi Tomas,

Does this work for renko/range (and other non-time based) bars built from 1-second data? The article mentions 1-minute data and I wanted to double-check.

Last edited 4 months ago by Wayne
Reply to  Wayne
20. 11. 2023 5:36 pm

Yes, it could work. SQ just expects OHLC data for rangebars

Continue reading