A group of functions intended for calculation of standard and custom indicators. For an expert (or any other MQL4 program) to take up the value of any indicator, it is not necessary that this indicator is present in the chart. The requested indicator will be loaded and calculated in the thread of the module that has called it.
Any indicator can be calculated on the data of not only current chart, but also on the 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()).
IAC
double iAC( string symbol, int timeframe, int shift)
Calculates the Bill Williams' Accelerator/Decelerator oscillator. 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:
double result=iAC(NULL, 0, 1);
IAD
double iAD( string symbol, int timeframe, int shift)
Calculates the Accumulation/Distribution indicator and returns its value. Parameters:
symbol - Symbol the data of which should be used to calculate indicator. 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:
127
IALLIGATOR
double
iAlligator(
string symbol, int timeframe, int jaw_period, int jaw_shift,
int teeth_period, int teeth_shift, int lips_period, int lips_shift,
int ma_method, int applied_price, int mode, int shift) Calculates the Bill Williams' Alligator and returns its value. Parameters:
symbol - Symbol the data of which should be used to calculate indicator.
NULL means the current symbol.
timeframe - Timeframe. It can be one of Timeframe enumeration values. 0
means the current chart timeframe.
jaw_period - Blue line averaging period (Alligator's Jaw).
jaw_shift - Blue line shift relative to the chart.
teeth_period - Red line averaging period (Alligator's Teeth).
teeth_shift - Red line shift relative to the chart.
lips_period - Green line averaging period (Alligator's Lips).
lips_shift - Green line shift relative to the chart.
ma_method - MA method. It can be any of Moving Average methods.
applied_price - Applied price. It can be any of Applied price enumeration values.
mode - Data source, identifier of a line of the indicator. It can be any of the
following values:
MODE_GATORJAW - Gator Jaw (blue) balance line, MODE_GATORTEETH - Gator Teeth (red) balance line, MODE_GATORLIPS - Gator Lips (green) balance line.
shift - Shift relative to the current bar (number of periods back) where the
data should be taken from. Sample:
double jaw_val=iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORJAW, 1);
IADX
double
iADX(
string symbol, int timeframe, int period, int applied_price, int mode,
int shift)
Calculates the Movement directional index and returns its value. Parameters:
symbol - Symbol the data of which should be used to calculate indicator.
NULL means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0
means the current chart timeframe.
period - Averaging period for calculation.
applied_price - Applied price. It can be any of Applied price enumeration values.
mode - Indicator line index. It can be any of the Indicators line identifiers
128
shift - Index of the value taken from the indicator buffer (shift relative to
the current bar the given amount of periods ago). Sample:
if(iADX(NULL,0,14,PRICE_HIGH,MODE_MAIN,0)>iADX(NULL,0,14,PRICE_HIGH,MO DE_PLUSDI,0)) return(0);
IATR
double iATR( string symbol, int timeframe, int period, int shift)
Calculates the Indicator of the average true range and returns its value. Parameters:
symbol - Symbol the data of which should be used to calculate indicator. NULL
means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means
the current chart timeframe.
period - Averaging period for calculation.
shift - Index of the value taken from the indicator buffer (shift relative to the
current bar the given amount of periods ago). Sample:
if(iATR(NULL,0,12,0)>iATR(NULL,0,20,0)) return(0);
IAO
double iAO( string symbol, int timeframe, int shift)
Calculates the Bill Williams' Awesome oscillator and returns its value. Parameters:
symbol - Symbol the data of which should be used to calculate indicator. 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:
double val=iAO(NULL, 0, 2);
IBEARSPOWER
double iBearsPower( string symbol, int timeframe, int period, int applied_price, int shift) Calculates the Bears Power indicator and returns its value.
Parameters:
symbol - Symbol the data of which should be used to calculate indicator.
NULL means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0
means the current chart timeframe.
period - Averaging period for calculation.
129
shift - Index of the value taken from the indicator buffer (shift relative to
the current bar the given amount of periods ago). Sample:
double val=iBearsPower(NULL, 0, 13,PRICE_CLOSE,0);
IBANDS
double
iBands(
string symbol, int timeframe, int period, int deviation, int bands_shift,
int applied_price, int mode, int shift)
Calculates the Bollinger bands indicator and returns its value. Parameters:
symbol - Symbol the data of which should be used to calculate the indicator.
NULL means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0
means the current chart timeframe.
period - Averaging period to calculate the main line.
deviation - Deviation from the main line.
bands_shift - The indicator shift relative to the chart.
applied_price - Applied price. It can be any of Applied price enumeration values.
mode - Indicator line index. It can be any of the Indicators line identifiers
enumeration value.
shift - Index of the value taken from the indicator buffer (shift relative to
the current bar the given amount of periods ago). Sample:
if(iBands(NULL,0,20,2,0,PRICE_LOW,MODE_LOWER,0)>Low[0]) return(0);
IBANDSONARRAY
double
iBandsOnArray(
double array[], int total, int period, int deviation, int bands_shift,
int mode, int shift)
Calculation of the Bollinger Bands indicator on data stored in a numeric array. Unlike iBands(...), the iBandsOnArray function does not take data by symbol name, timeframe, the applied price. The price data must be previously prepared. The indicator is
calculated from left to right. To access to the array elements as to a series array (i.e., from right to left), one has to use the ArraySetAsSeries function.
Parameters:
array[] - Array with data.
total - The number of items to be counted. 0 means the whole array.
period - Averaging period for calculation of main line.
deviation - Deviation from main line.
bands_shift - The indicator shift relative to the chart.
mode - Indicator line index. It can be any of the Indicators line identifiers
enumeration value.
130
current bar the given amount of periods ago). Sample:
if(iBands(ExtBuffer,total,2,0,MODE_LOWER,0)>Low[0]) return(0);
IBULLSPOWER
double iBullsPower( string symbol, int timeframe, int period, int applied_price, int shift) Calculates the Bulls Power indicator and returns its value.
Parameters:
symbol - Symbol the data of which should be used to calculate indicator.
NULL means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0
means the current chart timeframe.
period - Averaging period for calculation.
applied_price - Applied price. It can be any of Applied price enumeration values.
shift - Index of the value taken from the indicator buffer (shift relative to
the current bar the given amount of periods ago). Sample:
double val=iBullsPower(NULL, 0, 13,PRICE_CLOSE,0);
ICCI
double iCCI( string symbol, int timeframe, int period, int applied_price, int shift) Calculates the Commodity channel index and returns its value.
Parameters:
symbol - Symbol the data of which should be used to calculate indicator.
NULL means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0
means the current chart timeframe.
period - Averaging period for calculation.
applied_price - Applied price. It can be any of Applied price enumeration values.
shift - Index of the value taken from the indicator buffer (shift relative to
the current bar the given amount of periods ago). Sample:
if(iCCI(NULL,0,12,PRICE_TYPICAL,0)>iCCI(NULL,0,20,PRICE_TYPICAL,0)) return(0);
ICCIONARRAY
double iCCIOnArray( double array[], int total, int period, int shift)
Calculation of the Commodity Channel Index on data stored in a numeric array. Unlike iCCI(...), the iCCIOnArray function does not take data by symbol name, timeframe, the applied price. The price data must be previously prepared. The indicator is calculated from left to right. To access to the array elements as to a series array (i.e., from right to left), one has to use the ArraySetAsSeries function.
131
array[] - Array with data.
total - The number of items to be counted.
period - Averaging period for calculation.
shift - Index of the value taken from the indicator buffer (shift relative to the
current bar the given amount of periods ago). Sample:
if(iCCIOnArray(ExtBuffer,total,12,0)>iCCI(NULL,0,20,PRICE_TYPICAL, 0)) return(0);
ICUSTOM
double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift) Calculates the specified custom indicator and returns its value. The custom indicator must be compiled (*.EX4 file) and be in the terminal_directory\experts\indicators directory.
Parameters:
symbol - Symbol the data of which should be used to calculate indicator. NULL
means current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means
the current chart timeframe.
name - Custom indicator compiled program name.
... - Parameters set (if necessary). The passed parameters and their order must correspond with the desclaration order and the type of extern variables of the custom indicator.
mode - Line index. Can be from 0 to 7 and must correspond with the index
used by one of SetIndexBuffer functions.
shift - Index of the value taken from the indicator buffer (shift relative to the
current bar the given amount of periods ago). Sample:
double val=iCustom(NULL, 0, "SampleInd",13,1,0);
IDEMARKER
double iDeMarker( string symbol, int timeframe, int period, int shift) Calculates the DeMarker indicator and returns its value.
Parameters:
symbol - Symbol the data of which should be used to calculate indicator. NULL
means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means
the current chart timeframe.
period - Averaging period for calculation.
shift - Index of the value taken from the indicator buffer (shift relative to the
current bar the given amount of periods ago). Sample:
132
IENVELOPES
double
iEnvelopes(
string symbol, int timeframe, int ma_period, int ma_method,
int ma_shift, int applied_price, double deviation, int mode, int shift) Calculates the Envelopes indicator and returns its value.
Parameters:
symbol - Symbol the data of which should be used to calculate indicator.
NULL means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0
means the current chart timeframe.
ma_period - Averaging period for calculation of the main line.
ma_method - MA method. It can be any of Moving Average method enumeration
value.
ma_shift - MA shift. Indicator line offset relate to the chart by timeframe.
applied_price - Applied price. It can be any of Applied price enumeration values.
deviation - Percent deviation from the main line.
mode - Indicator line index. It can be any of Indicators line identifiers
enumeration value.
shift - Index of the value taken from the indicator buffer (shift relative to
the current bar the given amount of periods ago). Sample: double val=iEnvelopes(NULL, 0, 13,MODE_SMA,10,PRICE_CLOSE,0.2,MODE_UPPER,0); IENVELOPESONARRAY double iEnvelopesOnArray(
double array[], int total, int ma_period, int ma_method,
int ma_shift, double deviation, int mode, int shift) Calculation of the Envelopes indicator on data stored in a numeric array. Unlike iEnvelopes(...), the iEnvelopesOnArray function does not take data by symbol name, timeframe, the applied price. The price data must be previously prepared. The indicator is calculated from left to right. To access to the array elements as to a series array (i.e., from right to left), one has to use the ArraySetAsSeries function.
Parameters:
array[] - Array with data.
total - The number of items to be counted.
ma_period - Averaging period for calculation of the main line.
ma_method - MA method. It can be any of Moving Average method enumeration
value.
ma_shift - MA shift. Indicator line offset relate to the chart by timeframe.
deviation - Percent deviation from the main line.
mode - Indicator line index. It can be any of Indicators line identifiers
enumeration value.
shift - Index of the value taken from the indicator buffer (shift relative to the
133
Sample:
double val=iEnvelopesOnArray(ExtBuffer, 0, 13, MODE_SMA, 0.2, MODE_UPPER,0 );
IFORCE
double
iForce(
string symbol, int timeframe, int period, int ma_method, int applied_price,
int shift)
Calculates the Force index and returns its value. Parameters:
symbol - Symbol the data of which should be used to calculate indicator.
NULL means current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0
means the current chart timeframe.
period - Averaging period for calculation.
ma_method - MA method. It can be any of Moving Average method enumeration
value.
applied_price - Applied price. It can be any of Applied price enumeration values.
shift - Index of the value taken from the indicator buffer (shift relative to
the current bar the given amount of periods ago). Sample:
double val=iForce(NULL, 0, 13,MODE_SMA,PRICE_CLOSE,0);
IFRACTALS
double iFractals( string symbol, int timeframe, int mode, int shift) Calculates the Fractals and returns its value.
Parameters:
symbol - Symbol the data of which should be used to calculate indicator. NULL
means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means
the current chart timeframe.
mode - Indicator line index. It can be any of the Indicators line identifiers
enumeration value.
shift - Index of the value taken from the indicator buffer (shift relative to the
current bar the given amount of periods ago). Sample:
double val=iFractals(NULL, 0, MODE_UPPER, 3);
IGATOR
double
iGator(
string symbol, int timeframe, int jaw_period, int jaw_shift, int teeth_period,
int teeth_shift, int lips_period, int lips_shift, int ma_method,
134
Gator oscillator calculation. The oscillator displays the difference between the Alligator
red and blue lines (the upper histogram) and that between red and green lines (the lower histogram).
Parameters:
symbol - Symbol the data of which should be used to calculate indicator.
NULL means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0
means the current chart timeframe.
jaw_period - Blue line averaging period (Alligator's Jaw).
jaw_shift - Blue line shift relative to the chart.
teeth_period - Red line averaging period (Alligator's Teeth).
teeth_shift - Red line shift relative to the chart.
lips_period - Green line averaging period (Alligator's Lips).
lips_shift - Green line shift relative to the chart.
ma_method - MA method. It can be any of Moving Average method enumeration
value.
applied_price - Applied price. It can be any of Applied price enumeration values.
mode - Indicator line index. It can be any of Indicators line identifiers
enumeration value.
shift - Index of the value taken from the indicator buffer (shift relative to
the current bar the given amount of periods ago). Sample:
double jaw_val=iGator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_UPPER, 1);
IICHIMOKU
double
iIchimoku(
string symbol, int timeframe, int tenkan_sen, int kijun_sen,
int senkou_span_b, int mode, int shift) Calculates the Ichimoku Kinko Hyo and returns its value. Parameters:
symbol - Symbol the data of which should be used to calculate indicator.
NULL means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0
means the current chart timeframe.
tenkan_sen - Tenkan Sen averaging period.
kijun_sen - Kijun Sen averaging period.
senkou_span_b - Senkou SpanB averaging period.
mode - Source of data. It can be one of the Ichimoku Kinko Hyo mode
enumeration.
shift - Index of the value taken from the indicator buffer (shift relative to
the current bar the given amount of periods ago). Sample:
135
IBWMFI
double iBWMFI( string symbol, int timeframe, int shift)
Calculates the Bill Williams Market Facilitation index and returns its value. Parameters:
symbol - Symbol the data of which should be used to calculate indicator. 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:
double val=iBWMFI(NULL, 0, 0);
IMOMENTUM
double iMomentum( string symbol, int timeframe, int period, int applied_price, int shift) Calculates the Momentum indicator and returns its value.
Parameters:
symbol - Symbol the data of which should be used to calculate
indicator.NULL means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0
means the current chart timeframe.
period - Period (amount of bars) for calculation of price changes.
applied_price - Applied price. It can be any of Applied price enumeration values.
shift - Index of the value taken from the indicator buffer (shift relative to
the current bar the given amount of periods ago). Sample:
if(iMomentum(NULL,0,12,PRICE_CLOSE,0)>iMomentum(NULL,0,20,PRICE_CLOSE, 0)) return(0);
IMOMENTUMONARRAY
double iMomentumOnArray( double array[], int total, int period, int shift)
Calculation of the Momentum indicator on data stored in a numeric array. Unlike iMomentum(...), the iMomentumOnArray function does not take data by symbol name, timeframe, the applied price. The price data must be previously prepared. The indicator is calculated from left to right. To access to the array elements as to a series array (i.e., from right to left), one has to use the ArraySetAsSeries function.
Parameters:
array[] - Array with data.
total - The number of items to be counted.
period - Period (amount of bars) for calculation of price changes.
shift - Index of the value taken from the indicator buffer (shift relative to the
current bar the given amount of periods ago). Sample:
136
if(iMomentumOnArray(mybuffer,100,12,0)>iMomentumOnArray(mubuffer,100,2 0,0)) return(0);
IMFI
double iMFI( string symbol, int timeframe, int period, int shift) Calculates the Money flow index and returns its value.
Parameters:
symbol - Symbol the data of which should be used to calculate indicator. NULL
means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means
the current chart timeframe.
period - Period (amount of bars) for calculation of the indicator.
shift - Index of the value taken from the indicator buffer (shift relative to the
current bar the given amount of periods ago). Sample:
if(iMFI(NULL,0,14,0)>iMFI(NULL,0,14,1)) return(0);
IMA
double
iMA(
string symbol, int timeframe, int period, int ma_shift, int ma_method,
int applied_price, int shift)
Calculates the Moving average indicator and returns its value. Parameters:
symbol - Symbol the data of which should be used to calculate indicator.
NULL means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0
means the current chart timeframe.
period - Averaging period for calculation.
ma_shift - MA shift. Indicators line offset relate to the chart by timeframe.
ma_method - MA method. It can be any of the Moving Average method
enumeration value.
applied_price - Applied price. It can be any of Applied price enumeration values.