myeatrade

MQL4 Reference

MQL4 Timeseries access

A group of functions intended for access to price data of any available symbol/period.

If data (symbol name and/or timeframe differ from the current ones) are requested from another chart, the situation is possible that the corresponding chart was not opened in the client terminal and the necessary data must be requested from the server. In this case, error ERR_HISTORY_WILL_UPDATED (4066 – the requested history data are under updating) will be placed in the last_error variable, and one will has to re-request (see example of ArrayCopySeries()).

At the testing, price data of the same symbol but of another timeframe are modelled exactly, with the exception of volumes. Volumes of another timeframe are not modelled. Price data of other symbols are not modelled, either. In all cases, the amount of bars in time series is modelled exactly.

 

iBars()

int iBars(string symbol, int timeframe)

Returns the number of bars on the specified chart.

For the current chart, the information about the amount of bars is in the predefined variable named Bars.

Parameters:

symbol    - Symbol name of the security on the data of which the indicator will be calculated. NULL means the current symbol. 
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.  

Sample:

  Print("Bar count on the 'EUROUSD' symbol with PERIOD_H1 is",iBars("EUROUSD",PERIOD_H1));

iBarShift()

int iBarShift(string symbol, int timeframe, datetime time, bool exact=false)

Search for bar by open time. The function returns bar shift with the open time specified. If the bar having the specified open time is missing, the function will return -1 or the nearest bar shift depending on the exact.

Parameters:

symbol    - Symbol name of the security on the data of which the indicator will be calculated. NULL means the current symbol. 
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.  
time      - value to find (bar's open time). 
exact     - Return mode when bar not found. false - iBarShift returns nearest. true - iBarShift returns -1. 

Sample:

  datetime some_time=D'2004.03.21 12:00';
  int      shift=iBarShift("EUROUSD",PERIOD_M1,some_time);
  Print("shift of bar with open time ",TimeToStr(some_time)," is ",shift);

iClose()

int iClose(string symbol, int timeframe, int shift)

Returns Close value for the bar of indicated symbol with timeframe and shift. If local history is empty (not loaded), function returns 0.

For the current chart, the information about close prices is in the predefined array named Close[].

Parameters:

symbol    - Symbol name of the security on the data of which the indicator will be calculated. NULL means the current symbol. 
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.  
shift     - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago). 

Sample:

  Print("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,i),", ",  iOpen("USDCHF",PERIOD_H1,i),", ",
                                      iHigh("USDCHF",PERIOD_H1,i),", ",  iLow("USDCHF",PERIOD_H1,i),", ",
                                      iClose("USDCHF",PERIOD_H1,i),", ", iVolume("USDCHF",PERIOD_H1,i));

iHigh()

int iHigh(string symbol, int timeframe, int shift)

Returns High value for the bar of indicated symbol with timeframe and shift. If local history is empty (not loaded), function returns 0.

For the current chart, the information about high prices is in the predefined array named High[].

Parameters:

symbol    - Symbol name of the security on the data of which the indicator will be calculated. NULL means the current symbol. 
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.  
shift     - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago). 

Sample:

  Print("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,i),", ",  iOpen("USDCHF",PERIOD_H1,i),", ",
                                      iHigh("USDCHF",PERIOD_H1,i),", ",  iLow("USDCHF",PERIOD_H1,i),", ",
                                      iClose("USDCHF",PERIOD_H1,i),", ", iVolume("USDCHF",PERIOD_H1,i));

iHighest()

int iHighest(timeframe, int type, int count=WHOLE_ARRAY, int start=0)

Returns the shift of the maximum value over a specific number of periods depending on type.

Parameters:

symbol    - Symbol name of the security on the data of which the indicator will be calculated. NULL means the current symbol. 
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.  
type      - Series array identifier. It can be any of the Series array identifier enumeration values. 
count     - Number of periods (in direction from the start bar to the back one) on which the calculation is carried out. 
start     - Shift showing the bar, relative to the current bar, that the data should be taken from. 

Sample:

  double val;
  // calculating the highest value on the 20 consequtive bars in the range
  // from the 4th to the 23rd index inclusive on the current chart
  val=High[iHighest(NULL,0,MODE_HIGH,20,4)];

iLow()

int iLow(string symbol, int timeframe, int shift)

Returns Low value for the bar of indicated symbol with timeframe and shift. If local history is empty (not loaded), function returns 0.

For the current chart, the information about high prices is in the predefined array named Low[].

Parameters:

symbol    - Symbol name of the security on the data of which the indicator will be calculated. NULL means the current symbol. 
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.  
shift     - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago). 

Sample:

  Print("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,i),", ",  iOpen("USDCHF",PERIOD_H1,i),", ",
                                      iHigh("USDCHF",PERIOD_H1,i),", ",  iLow("USDCHF",PERIOD_H1,i),", ",
                                      iClose("USDCHF",PERIOD_H1,i),", ", iVolume("USDCHF",PERIOD_H1,i));

iLowest()

int iLowest(timeframe, int type, int count=WHOLE_ARRAY, int start=0)

Returns the shift of the least value over a specific number of periods depending on type.

Parameters:

symbol    - Symbol name of the security on the data of which the indicator will be calculated. NULL means the current symbol. 
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.  
type      - Series array identifier. It can be any of the Series array identifier enumeration values. 
count     - Number of periods (in direction from the start bar to the back one) on which the calculation is carried out. 
start     - Shift showing the bar, relative to the current bar, that the data should be taken from. 

Sample:

// calculating the lowest value on the 10 consequtive bars in the range
// from the 10th to the 19th index inclusive on the current chart
double val=Low[iLowest(NULL,0,MODE_LOW,10,10)];

iOpen()

int iOpen(string symbol, int timeframe, int shift)

Returns Open value for the bar of indicated symbol with timeframe and shift. If local history is empty (not loaded), function returns 0.

For the current chart, the information about open prices is in the predefined array named Open[].

Parameters:

symbol    - Symbol name of the security on the data of which the indicator will be calculated. NULL means the current symbol. 
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.  
shift     - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago). 

Sample:

  Print("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,i),", ",  iOpen("USDCHF",PERIOD_H1,i),", ",
                                      iHigh("USDCHF",PERIOD_H1,i),", ",  iLow("USDCHF",PERIOD_H1,i),", ",
                                      iClose("USDCHF",PERIOD_H1,i),", ", iVolume("USDCHF",PERIOD_H1,i));

iTime()

int iTime(string symbol, int timeframe, int shift)

Returns Time value for the bar of indicated symbol with timeframe and shift. If local history is empty (not loaded), function returns 0.

For the current chart, the information about bars open times is in the predefined array named Time[].

Parameters:

symbol    - Symbol name of the security on the data of which the indicator will be calculated. NULL means the current symbol. 
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.  
shift     - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago). 

Sample:

  Print("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,i),", ",  iOpen("USDCHF",PERIOD_H1,i),", ",
                                      iHigh("USDCHF",PERIOD_H1,i),", ",  iLow("USDCHF",PERIOD_H1,i),", ",
                                      iClose("USDCHF",PERIOD_H1,i),", ", iVolume("USDCHF",PERIOD_H1,i));

iVolume()

int iVolume(string symbol, int timeframe, int shift)

Returns Tick Volume value for the bar of indicated symbol with timeframe and shift. If local history is empty (not loaded), function returns 0.

For the current chart, the information about bars tick volumes is in the predefined array named Volume[].

Parameters:

symbol    - Symbol name of the security on the data of which the indicator will be calculated. NULL means the current symbol. 
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.  
shift     - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago). 

Sample:

  Print("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,i),", ",  iOpen("USDCHF",PERIOD_H1,i),", ",
                                      iHigh("USDCHF",PERIOD_H1,i),", ",  iLow("USDCHF",PERIOD_H1,i),", ",
                                      iClose("USDCHF",PERIOD_H1,i),", ", iVolume("USDCHF",PERIOD_H1,i));
This article url: http://www.myeatrade.com/456/

Please login to post comment, if you haven't account you can register free