• Overview
  • Reviews (4)
  • Comments (3)
  • What's new

Library for Custom Chart

LibCustomChart library allows to write indicators and Expert Advisors compatible with custom charts created by iCustomChart. Example of the library use in indicators and Expert Advisors can be found in Code Base.

iCustomChart demo version can be downloaded for free.

Basic library functions:

  • CustomChartInit - automatically connects a new indicator or an Expert Advisor to a custom chart uploaded to the terminal chart window by iCustomChart. If a custom chart is not uploaded, all library functions will use the data of the current chart window symbol. The function is called only in OnInit(). 
    bool CustomChartInit(void);
    
    Parameters:
    no.

    Returned values:
    false - in case of an error.
    true - in case of successful execution.

    Note: the absence of iCustomChart custom chart is not considered as an error. If the custom chart has been detected, the appropriate message will appear in the journal.

  • CustomChartRefresh - updates the data of the iCustomChart custom chart for further use. This is a mandatory function included once in OnCalculate() or OnTick() before all other used library functions.
    bool CustomChartRefresh(void);
    
    Parameters:
    no.

    Returned values:
    false - in case of an error.
    true - in case of successful execution.

    Note: if iCustomChart has not been uploaded, the data of the current chart window symbol will be used.

  • CustomChartSync - synchronizes the indicator buffer with iCustomChart chart. Called after CustomChartRefresh() in OnCalculate().
    bool CustomChartSync(double &buffer[]);
    
    Parameters:
    buffer[] - [out] the indicator buffer that must be synchronized with iCustomChart.

    Returned values:
    false - in case of an error.
    true - in case of successful execution.

    Note: if iCustomChart has not been detected, the indicator buffer will be synchronized with the bars of the current chart window. If the indicator buffer is not synchronized by CustomChartSync() function, it acts synchronically with the bars of the current chart window.
The functions of access to the custom chart time series by the element position
CopyOpen - the function returns the value of the specified bar open price.
CopyClose - the function returns the value of the specified bar close price.
CopyHigh - the function returns the value of the specified bar high price.
CopyLow - the function returns the value of the specified bar low price.
CopyTime - the function returns the value of the specified bar open time.
CopyRealVolume - the function returns the value of the specified bar trading volume.
CopyTickVolume - the function returns the value of the specified bar tick volume.
CopySpread - the function returns the value of the specified bar spread.
CopyZeroBuffer - the function returns the value of the specified bar zero buffer.
CopyRates - the function returns the value as the specified bar MqlRates structure.
CopyAppliedPrice - the function returns the value of the bar data according to the selected price basis for the calculations.
CopyColor - the function returns the value of the specified bar color index.
MqlRates CopyRates(int position);
datetime CopyTime(int position);
double   CopyOpen(int position);
double   CopyClose(int position);
double   CopyHigh(int position);
double   CopyLow(int position);
double   CopyZeroBuffer(int position);
double   CopyAppliedPrice(ENUM_APPLIED_PRICE _applied_price, int position);
long     CopyRealVolume(int position);
long     CopyTickVolume(int position);
int      CopySpread(int position);
int      CopyColor(int position);
Parameters:
position - [in] time series bar index.

Returned values:

The specified time series bar value is returned.

Note: if iCustomChart has not been detected, the data from the current chart window symbol will be used. It should be noted that the functions of access to the custom chart time series have the same peculiarities as conventional functions of access to time series and indicators. Called after CustomChartRefresh() in OnCalculate() or OnTick().
The functions of access to the custom chart time series by the initial position and the number of elements
CopyOpen - the function gets the opening prices of the bars of the custom chart to the data array in a specified amount.
CopyClose - the function gets the closing prices of the bars of the custom chart to the data array in a specified amount.
CopyHigh - the function gets the high prices of the bars of the custom chart to the data array in a specified amount.
CopyLow - the function gets the low prices of the bars of the custom chart to the data array in a specified amount.
CopyTime - the function gets the opening time of the bars of the custom chart to the data array in a specified amount.
CopyRealVolume - the function gets the trading volumes of the bars of the custom chart to the data array in a specified amount.
CopyTickVolume - the function gets the tick volumes of the bars of the custom chart to the data array in a specified amount.
CopySpread - the function gets the spreads of the bars of the custom chart to the data array in a specified amount.
CopyZeroBuffer - the function gets the zero buffer bars value of the custom chart to the data array in a specified amount.
CopyRates - the function gets the data in the form of MqlRates structure to the data array in a specified amount.
CopyAppliedPrice - the function gets the values according to the selected price base for calculations to the data array.
CopyColor - the function gets the value of the color index of the bars of the custom chart to the data array in a specified amount.
int      CopyTime(int start_pos,int count,datetime &array[]);
int      CopyOpen(int start_pos,int count,double &array[]);
int      CopyClose(int start_pos,int count,double &array[]);
int      CopyHigh(int start_pos,int count,double &array[]);
int      CopyLow(int start_pos,int count,double &array[]);
int      CopyRealVolume(int start_pos,int count,long &array[]);
int      CopyTickVolume(int start_pos,int count,long &array[]);
int      CopySpread(int start_pos,int count,int &array[]);
int      CopyZeroBuffer(int start_pos,int count,double &array[]);
int      CopyRates(int start_pos, int count, MqlRates &array[]);
int      CopyAppliedPrice(ENUM_APPLIED_PRICE _applied_price, int start_pos, int count, double &array[]);
int      CopyColor(int start_pos,int count,int &array[]);
Parameters:
start_pos - [in] first copied element index.
count- [in] the number of copied elements.
array[] - [out] the array for receiving data.

Returned values:

The number of the copied array elements or -1 in case of an error.

Note: if iCustomChart has not been detected, the data from the current chart window symbol will be used. It should be noted that the functions of access to the custom chart time series have the same peculiarities as conventional functions of access to time series and indicators. Called after CustomChartRefresh() in OnCalculate() or OnTick().
The functions of getting the custom chart properties
  • CustomChartHandle - the function returns iCustomChart indicator handle. Called after CustomChartRefresh() in OnCalculate() or OnTick().
    int CustomChartHandle(void);
    Parameters:
    no.

    Returned values:

    iCustomChart indicator handle or INVALID_HANDLE, in case iCustomChart is not detected.

    Note: if iCustomChart has not been detected, the data from the current chart window symbol will be used.
  • CustomChartName - the function returns the short name of iCustomChart indicator. Called after CustomChartRefresh() in OnCalculate() or OnTick().
    string CustomChartName(void);
    Parameters:
    no.

    Returned values:

    iCustomChart indicator short name or NULL, in case an error or iCustomChart have not been detected.

    Note: if iCustomChart has not been detected, the data from the current chart window symbol will be used.
  • CustomChartFile - the function returns the iCustomChart indicator file name. Called after CustomChartRefresh() in OnCalculate() or OnTick().
    string CustomChartFile(void);
    Parameters:
    no.

    Returned values:

    iCustomChart indicator file name or NULL, in case an error or iCustomChart have not been detected.

    Note: if iCustomChart has not been detected, the data from the current chart window symbol will be used. The file name returned by the function is formed relative to the "terminal_data_folder\MQL5\Indicators" directory.
  • CustomChartIsAttach - the function returns the feature displaying that an indicator using the library has been attached to iCustomChart. Called after CustomChartRefresh() in OnCalculate() or OnTick().
    bool CustomChartIsAttach(void);
    Parameters:
    no.

    Returned values:
    false - in case an indicator is not attached to iCustomChart.

    true - in case an indicator is attached to iCustomChart.

    Note: in case the indicator is not attached to iCustomChart, the library functions will use the symbol data from the current chart window.
  • CustomChartHstFile - the function returns the history file name that uses iCustomChart. Called after CustomChartRefresh() in OnCalculate() or OnTick().
    string CustomChartHstFile(void);
    Parameters:
    no.

    Returned values:

    The history file name or NULL, in case an error has occurred or iCustomChart has not been detected.

    Note: if iCustomChart has not been detected, the data from the current chart window symbol will be used. iCustomChart history file is searched relative to "terminal_data_folder\MQL5\Files\iCustomChart\History" directory. The history file name returned by the function is formed relative to the same directory.
  • CustomChartBars - the function returns the amount of the custom chart bars. Called after CustomChartRefresh() in OnCalculate() or OnTick().
    int CustomChartBars(void);
    Parameters:
    no.

    Returned values:

    the amount of the custom chart bars.

    Note: if iCustomChart has not been detected, the data from the current chart window symbol will be used.

  • CustomChartBegin - the function returns the index of the first significant bar of the custom chart. Called after CustomChartRefresh() in OnCalculate() or OnTick().
    int CustomChartBegin(void);
    Parameters:
    no.

    Returned values:

    the index of the first significant bar of the custom chart.

    Note: if iCustomChart has not been detected, the data from the current chart window symbol will be used.

  • CustomChartNewBars - the function returns the amount of the newly appeared bars of the custom chart. Called after CustomChartRefresh() in OnCalculate() or OnTick().
    int CustomChartNewBars(void);
    Parameters:
    no.

    Returned value:

    the amount of the newly appeared custom chart bars.

    Note: if iCustomChart has not been detected, the data from the current chart window symbol will be used.

The contents of the included file with the library functions description

#import "LibCustomChart.ex5"
   //--- Basic Functions:
   bool CustomChartInit(void);
   bool CustomChartRefresh(void);
   //--- the function of the indicator buffer synchronization with iCustomChart:
   bool CustomChartSync(double &buffer[]);
   //--- the function of the access to iCustomChart time series data by the element position:
   MqlRates CopyRates(int position);
   datetime CopyTime(int position);
   double   CopyOpen(int position);
   double   CopyClose(int position);
   double   CopyHigh(int position);
   double   CopyLow(int position);
   double   CopyZeroBuffer(int position);
   double   CopyAppliedPrice(ENUM_APPLIED_PRICE _applied_price, int position);
   long     CopyRealVolume(int position);
   long     CopyTickVolume(int position);
   int      CopySpread(int position);
   int      CopyColor(int position);
   //--- the function of the access to iCustomChart time series data by the initial position and the number of elements:
   int      CopyTime(int start_pos,int count,datetime &array[]);
   int      CopyOpen(int start_pos,int count,double &array[]);
   int      CopyClose(int start_pos,int count,double &array[]);
   int      CopyHigh(int start_pos,int count,double &array[]);
   int      CopyLow(int start_pos,int count,double &array[]);
   int      CopyRealVolume(int start_pos,int count,long &array[]);
   int      CopyTickVolume(int start_pos,int count,long &array[]);
   int      CopySpread(int start_pos,int count,int &array[]);
   int      CopyZeroBuffer(int start_pos,int count,double &array[]);
   int      CopyRates(int start_pos, int count, MqlRates &array[]);
   int      CopyAppliedPrice(ENUM_APPLIED_PRICE _applied_price, int start_pos, int count, double &array[]);
   int      CopyColor(int start_pos,int count,int &array[]);
   //--- the function of the access to iCustomChart properties:   
   int      CustomChartBars(void);
   int      CustomChartBegin(void);
   int     CustomChartNewBar(void);
   bool     CustomChartIsAttach(void);
   int      CustomChartHandle(void);
   string   CustomChartHstFile(void);
   string   CustomChartFile(void);
   string   CustomChartName(void);
#import
Ali irwan
4873
2017.08.02 15:14 
 

User didn't leave any comment to the rating

Nork
6028
2017.07.21 14:44 
 

User didn't leave any comment to the rating

Rodrigo da Silva Boa
7121
2015.12.13 10:01 
 

User didn't leave any comment to the rating

Vadim Strelkov
7934
2014.04.08 12:46 
 

User didn't leave any comment to the rating

Version 1.10 - 2015.06.19
1. Now supports iTicksChart (https://www.mql5.com/en/market/product/803)
2. Added functions of access to Ask, Bid, Last prices of the custom chart by the element position:
double CopyAsk(int position);
double CopyBid(int position);
double CopyLast(int position);
3. Added functions of access to Ask, Bid, Last prices of the custom chart by the initial position and the number of elements
int CopyAsk(int start_pos,int count,double &array[]);
int CopyBid(int start_pos,int count,double &array[]);
int CopyLast(int start_pos,int count,double &array[]);

Note: if iTicksChart has not been detected, the data from the current chart window symbol will be used. Functions are called after CustomChartRefresh() in OnCalculate() or OnTick(). For details, see the main description of the library.
Version 1.9 - 2013.09.09
Fixed error in function CopyTime(int position).
Version 1.8 - 2013.09.06
Fixed CustomChartBars() error that could appear in the strategy tester.