You are on page 1of 7

v

CUSTOM TIMEFRAME
GENERATOR

fxblue.com
CUSTOM TIMEFRAME GENERATOR

1. Overview of the Custom Timeframe Generator ................................................................ 2


1.1 Purpose of the Custom Timeframe Generator............................................................. 2
1.2 Licence ........................................................................................................................ 2
2. Using the Custom Timeframe Generator ........................................................................... 3
2.1 Installing the Custom Timeframe Generator ............................................................... 3
2.2 Running the Custom Timeframe Generator ................................................................ 3
2.3 Other Generator EA settings ....................................................................................... 4
2.3.1 ContinueExistingFile ........................................................................................... 4
2.3.2 InterpolateEmptyBars .......................................................................................... 4
2.3.3 CreateHistory ....................................................................................................... 5
2.3.4 SendTicks ............................................................................................................. 5
2.3.5 BarShiftMinutes ................................................................................................... 5
2.3.6 ShowRenkoTails .................................................................................................. 6
2.3.7 CustomPipSize ..................................................................................................... 6
2.4 Deleting old custom charts .......................................................................................... 6

Page 1 of 6
CUSTOM TIMEFRAME GENERATOR

1. Overview of the Custom Timeframe Generator


1.1 Purpose of the Custom Timeframe Generator
The Custom Timeframe Generator lets you create charts for timeframes which are not
available by default in MetaTrader 4:

 Periods such as M2, M3, M10, and H2


 Second charts (e.g. 10 seconds)
 Tick charts
 Range bars
 Renko bars

Most EAs and indicators will work correctly on these custom charts. However, you should
test things carefully before trading real money, because there are subtle differences between
normal charts and the custom charts which could potentially cause problems with some MT4
code.

1.2 Licence
Unless otherwise specified in writing by FX Blue, this software is licensed for personal
use only. You are not allowed to distribute it to other people, regardless of whether or
not money is changing hands. You only have a licence to use the software if you,
personally, downloaded it from our website.

The software is provided entirely at the user’s risk, and you should check it thoroughly
before deploying it on computers trading real money. FX Blue accepts no responsibility
whatsoever for any loss of any kind caused by installation or use of the software.

Page 2 of 6
CUSTOM TIMEFRAME GENERATOR

2. Using the Custom Timeframe Generator


2.1 Installing the Custom Timeframe Generator
To install the Generator, run the setup program. You can choose one or more copies of
MetaTrader 4 where you want to install the EA. If any copies of MT4 are not shown, you can
add them to the list using the “Find MT4” button.

MT4 needs to be restarted in order for its Navigator list to update after new EAs are installed.

2.2 Running the Custom Timeframe Generator


In order to create a chart for a custom timeframe, you need to do two main things:

 Run the Generator EA on a (normal) chart for the symbol


 Once the Generator EA is running, open the custom timeframe which is added to the
list of offline charts

The chart for the custom timeframe will only update while the Generator EA is running on
the other (normal) chart.

In more detail, the steps are as follows:

 Open a chart for the symbol, e.g. EURUSD, to host the Generator EA. You can use
any timeframe for this normal chart, but M1 is best if you want the Generator EA to
fill in historic data.
 Add the Generator EA to the chart (by double-clicking on it in MT4’s Navigator list,
or by dragging it from the Navigator onto the chart).
 On the Common tab of the EA’s settings, turn on the “Allow DLL imports” option.
 On the Inputs tab of the EA’s settings, change the following options:
 Choose one of the following, leaving the others set to zero:
 Set BarPeriodSeconds if you want a chart with bars every N seconds (e.g. 10
for 10 seconds, or 180 for M3, or 7200 for H2).
 Or, set BarPeriodTicks if you want a chart with bars every N ticks.
 Or, set RangeBarPips to a number of pips if you want to draw range bars.
 Or, set RenkoBarPips to a number of pips if you want to draw Renko bars.
 Set ShowAsOfflinePeriod to a value which you will use to identify this custom
chart. For example, you could use 1010 to mean “10-second chart” and 2010 to
mean “10-tick chart”. The meaning and numbering of ShowAsOfflinePeriod is

Page 3 of 6
CUSTOM TIMEFRAME GENERATOR
entirely up to you, and has no effect on the chart’s behaviour. If you are running
multiple copies of the Generator, then each one should have a different
ShowAsOfflinePeriod setting.
 Once the Generator EA is successfully running, open the custom chart:
 Click on File | Offline Chart
 Choose the entry corresponding to the ShowAsOfflinePeriod parameter. For
example, if you used the value 2010, then the custom offline chart will be listed as
“EURUSD,M2010”

The chart for your custom timeframe will open and start drawing, and will continue to update
for as long as the Generator EA is running on its host chart.

By default, the bespoke chart will start from the time that you run the Generator EA, and will
not contain any historic data. However, under some circumstances it is possible to use the
CreateHistory parameter to tell the Generator EA to calculate historic bars.

2.3 Other Generator EA settings


In addition to the parameters described above, the Generator EA has some further settings
which you can use to customize its behaviour.

2.3.1 ContinueExistingFile

By default the ContinueExistingFile parameter is turned off, and the Generator EA will
restart the custom offline chart from scratch. If you turn ContinueExistingFile on, then the
Generator EA will add new ticks and bars to any existing contents of the offline file.

2.3.2 InterpolateEmptyBars

If you use the Generator EA to create charts for short timeframes (e.g. 10 seconds), then there
can be periods where no tick occurs and no bar is drawn. (Similarly, on a normal M1 chart,
there are usually a few “missing” bars per day because no ticks happened during those
minutes. There can be even be gaps on M5 and M15 charts if the market is very quiet.)

If you turn on InterpolateEmptyBars, then the Generator EA will create a dummy bar for each
period during which no ticks occurred. It will use the previous close as the OHLC of the
dummy bar, and it records the volume as zero. The dummy bars are created after the gap,
when the first tick of the new bar occurs.

Page 4 of 6
CUSTOM TIMEFRAME GENERATOR
These extra empty bars can help to identify quiet periods in the market, but please note that
they will affect indicator calculations. For example, a moving average will include the
dummy bars (whereas on a normal M1 chart, for example, an indicator will not take into
account any bars which are “missing”).

InterpolateEmptyBars cannot be used with tick charts or range charts (i.e. where
BarPeriodTicks > 0 or RangeBarPips > 0 or RenkoBarPips > 0), simply because there cannot
be “missing” bars on a tick or range chart.

2.3.3 CreateHistory

The CreateHistory parameter can only be used on time charts, not tick charts or range charts,
and only when the bar period is a number of minutes. In other words, you can only use
CreateHistory if BarPeriodSeconds is exactly divisible by 60.

This setting tells the Generator EA to read the M1 data stored in MetaTrader 4, and to create
historic bars for your bespoke timeframe. For example, if BarPeriodSeconds is set to 180 (i.e.
3 minutes), then CreateHistory will use the available M1 data to create historic M3 bars, as
well as then continuing to draw new M3 bars going forwards. In other words, CreateHistory
is similar to the period_converter script which is supplied by default with MT4.

CreateHistory cannot be used on tick charts or on time periods less than 1-minute because it
is impossible to calculate this historic data from MT4’s M1 bar history. Such charts can only
be drawn on a forward basis.

In order to use CreateHistory you need to have M1 data within MT4. You can get M1 data
either by opening an M1 chart for the symbol, or by using the History Center to download the
data manually.

2.3.4 SendTicks

The SendTicks parameter is an aid for running automated systems (EAs) on the offline chart.
This parameter tells the Generator to send simulated ticks to the offline chart, which can force
an EA on the automated chart to run.

2.3.5 BarShiftMinutes

The BarShiftMinutes parameter can be used to adjust the start time of bars on the offline
chart. It is only applicable to time charts; it is ignored with tick charts and range bars.

Page 5 of 6
CUSTOM TIMEFRAME GENERATOR
For example, you can set BarPeriodSeconds to 3600 in order to create H1 bars, but set
BarShiftMinutes to -60 so that the time of the adjusted bars is one hour behind the broker’s
time.

2.3.6 ShowRenkoTails

If you are using Renko bars (RenkoBarPips > 0) then you can turn on the ShowRenkoTails
option in order to show the amount of "adverse" or "incomplete" opposite move on each bar
which is usually trimmed off a Renko chart. This can help to indicate the strength of a trend,
and signal the end of a trend. For example, in the following screenshot the length of the tails
indicates the strength of the move:

2.3.7 CustomPipSize

By default the Generator will use a pip size (for range and Renko charts) which is derived
from the number of decimal places to which a price is quoted. For example, if a price is
quoted to 4DP or 5DP then the pip size will be 0.0001; if the price is quoted to 2DP or 3DP
then the pip size will be 0.01.

Particularly for use on non-forex symbols, you can override this using the CustomPipSize
parameter. For example, if the Dax index is quoted to 2DP but you want the pip size to be
1.00 rather than 0.01, then you can set CustomPipSize to 1.

2.4 Deleting old custom charts


When you have finished with a custom chart, you can either overwrite it (by running the
Generator EA with the same ShowAsOfflinePeriod parameter and with ContinueExistingFile
turned off), or you can manually delete the history file from the history\<broker-server>
directory within the MT4 installation.

Page 6 of 6

You might also like