iCustomChart indicator allows to create custom charts based on custom history files. Open history file format is used.
iCustomChart demo version can be downloaded for free.
Contents:
- Advantages and Features
- Input Parameters
- Indicator Buffers
- Data Window
- History Files
- Graphical Objects for Technical Analysis
- Indicators and Experts
1. Advantages and Features
- works at any open chart window (called "base chart" further on in this document);
- looks like a common chart after uploading (see Screenshots);
- open history file format is used;
- MetaTrader 4 and 5 data format can be used;
- allows to create the charts of synthetic or non-standard symbols;
- has built-in Data Window (see Screenshot 4);
- major part of the objects from the MetaTrader 5 standard set can be used for technical analysis (see Screenshot 2);
- both online and offline charts can be created;
- bars opening time can be controlled up to milliseconds;
- user indicators and Expert Advisors can be created based on synthetic symbol chart (see Screenshots 3, 6).
2. Input Parameters
3. Indicator Buffers
Indicator buffer index | Contents |
---|
0 | Contains selected price constant. The buffer allows other indicators that use the first form to get the data.
|
1 | Bar opening time
|
2 | Bar opening price
|
3 | Bar high price
|
4 | Bar low price
|
5 | Bar closing price
|
6 | Bar color
|
7 | Market volume
|
8 | Tick volume
|
9 | Spread
|
4. Data Window
Built-in data window looks similar to the conventional MetaTrader 5 data window but has some additions (Screenshot 4). Data fields displayed in the window:
- Upper field - symbol name and parameter. Parameter is the value of the "parameter" variable of a history file header (see description of a history file format). Parameter standard values mean selected symbol period. The window containing data on a history file will be downloaded after this field is clicked on (Screenshot 5).
- Date - bar opening date.
- Time - bar opening time.
- Open - bar opening price.
- High - bar high price.
- Low - bar low price.
- Close - bar closing price.
- Volume - market volume.
- Tick Volume - tick volume.
- Spread - bar spread.
- Bar - bar index, zero bar - last unfinished bar.
5. History Files (HST Files)
Open history files format described in the
MetaTrader 4 user guide. Users can take a ready-made history file or create it themselves. Then iCustomChart indicator can be used for a chart display.
History file format is the following one. History file header goes first:
struct HistoryHeader
{
int version
char copyright[64];
char symbol[12];
int parameter;
int digits;
time_t timesign;
time_t last_sync;
int unused[13];
};
The version of the base for MetaTrader 4 history files is displayed
as "400", while for MetaTrader 5 it is "500". This is important, as
each version has its own bar data structure.
The standard representation of the bars array following the header for the version "400" history file looks as follows:
#pragma pack(push,1)
struct RateInfo
{
time_t ctm;
double open; // bar opening price
double low; // bar low price
double high; // bar high price
double close; // bar closing price
double vol; // volume
};
#pragma pack(pop)
The standard representation of the bars array for the version "500" history file looks as follows:
#pragma pack(push,1)
struct MqlRates
{
datetime time; // bar time in seconds or milliseconds
double open; // open price
double high; // high price for the period
double low; // low price for the period
double close; // closing price
long tick_volume; // tick volume
int spread; // spread
long real_volume; // market volume
};
#pragma pack(pop)
Note that bar time can be set either in seconds or in milliseconds for
version "500". iCustomChart can correctly recognize both time formats.
Note: users bear responsibility for a history file correctness.
6. Graphical Objects for Technical Analysis
Standard graphical objects of the terminal are bound to a base chart time scale when placed in a
chart window. Time scale of custom charts created using iCustomChart does not always coincide with a base chart time scale. Therefore, iCustomChart automatically binds used graphical objects to its time scale. Synchronization with iCustomChart is supported for the following conventional MetaTrader 5 graphical objects:
- lines: horizontal, vertical, trendlines, trends by angle, cycle, arrowed;
- channels: equidistant, Andrews Pitchfork;
- Fibonacci: retracement, time zones, fan, arcs, channel, expansion;
- Elliott: motive wave, corrective wave;
- shapes: triangle, rectangle, ellipse;
- arrows: thumbs up, thumbs down, arrow down, arrow up, stop sign, check sign, left and right price labels, Buy and Sell signs, arrow.
In some cases, for example when closing the terminal, iCustomChart saves the objects data to a temporary file located in the "terminal_data_folder\MQL5\Files\iCustomChart\Objects" directory. The system deletes all temporary files when iCustomChart is being removed from a chart window.
7. Indicators and Experts
Common indicators follow the time scale of a base chart, as well as the objects. Free LibCustomChart library should be used for binding the indicators to the iCustomChart time scale.
The library functions allow to write the indicators that are automatically connected to iCustomChart (Screenshot 3), in case it is uploaded to a chart window. In case iCustomChart is not uploaded,
these indicators will work in a common chart window. Besides, the library provides simplified access to iCustomChart time series.
In case the library functions are used in an Expert Advisor, then it will also automatically use iCustomChart data, in case the latter has already been uploaded to a chart window. In case iCustomChart is not uploaded, the Expert Advisor will work in a common chart window and use its data.
Examples of the library use in indicators and Expert Advisors can be found in Code Base.
iCustomChart demo version can be downloaded for free.