myeatrade

MQL4 Reference

MQL4 Technical indicators (4)

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()).

 

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        - 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(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.  
shift         - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago). 

Sample:

  AlligatorJawsBuffer[i]=iMA(NULL,0,13,8,MODE_SMMA,PRICE_MEDIAN,i);

iMAOnArray()

double iMAOnArray(double array[], int total, int period, 
                  int ma_shift, int ma_method, int shift)

Calculation of the Moving Average on data stored in a numeric array. Unlike iMA(…), the iMAOnArray 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 whole array. 
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. 
shift     - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago). 

Sample:

   double macurrent=iMAOnArray(ExtBuffer,0,5,0,MODE_LWMA,0);
   double macurrentslow=iMAOnArray(ExtBuffer,0,10,0,MODE_LWMA,0);
   double maprev=iMAOnArray(ExtBuffer,0,5,0,MODE_LWMA,1);
   double maprevslow=iMAOnArray(ExtBuffer,0,10,0,MODE_LWMA,1);
   //----
   if(maprev<maprevslow && macurrent>=macurrentslow)
     Alert("crossing up");

iOsMA()

double iOsMA(string symbol, int timeframe, 
             int fast_ema_period, int slow_ema_period, int signal_period, 
             int applied_price, int shift)

Calculates the Moving Average of Oscillator and returns its value. Sometimes called MACD Histogram in some systems.

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. 
fast_ema_period - Number of periods for fast moving average calculation. 
slow_ema_period - Number of periods for slow moving average calculation. 
signal_period   - Number of periods for signal moving average 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(iOsMA(NULL,0,12,26,9,PRICE_OPEN,1)>iOsMA(NULL,0,12,26,9,PRICE_OPEN,0)) return(0);

iMACD()

double iMACD(string symbol, int timeframe, 
             int fast_ema_period, int slow_ema_period, int signal_period, 
             int applied_price, int mode, int shift)

Calculates the Moving averages convergence/divergence and returns its value. In the systems where OsMA is called MACD Histogram, this indicator is displayed as two lines. In the Client Terminal, the Moving Average Convergence/Divergence is drawn as a 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. 
fast_ema_period - Number of periods for fast moving average calculation. 
slow_ema_period - Number of periods for slow moving average calculation. 
signal_period   - Number of periods for signal moving average calculation. 
applied_price   - Applied price. It can be any of Applied price enumeration values. 
mdoe            - 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(iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)>iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0)) return(0);

iOBV()

double iOBV(string symbol, int timeframe, int applied_price, int shift)

Calculates the On Balance Volume 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. 
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=iOBV(NULL, 0, PRICE_CLOSE, 1);

iSAR()

double iSAR(string symbol, int timeframe, double step, 
            double maximum, int shift)

Calculates the Parabolic Stop and Reverse system 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. 
step      - Increment, usually 0.02.
maximum   - Maximum value, usually 0.2. 
shift     - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago). 

Sample:

  if(iSAR(NULL,0,0.02,0.2,0)>Close[0]) return(0);

iRSI()

double iRSI(string symbol, int timeframe, int period, 
            int applied_price, int shift)

Calculates the Relative strength 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(iRSI(NULL,0,14,PRICE_CLOSE,0)>iRSI(NULL,0,14,PRICE_CLOSE,1)) return(0);

iRSIOnArray()

double iRSIOnArray(double array[], int total, int period, int shift)

Calculation of the Relative Strength Index on data stored in a numeric array. Unlike iRSI(…), the iRSIOnArray 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[] - Symbol the data of which should be used to calculate indicator. NULL means the current symbol. 
total   - 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(iRSIOnArray(ExtBuffer,1000,14,0)>iRSI(NULL,0,14,PRICE_CLOSE,1)) return(0);

iRVI()

double iRVI(string symbol, int timeframe, int period, int mode, int shift)

Calculates the Relative Vigor 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    - Number of periods for calculation. 
mdoe      - 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=iRVI(NULL, 0, 10,MODE_MAIN,0);

iStdDev()

double iStdDev(string symbol, int timeframe, int ma_period, 
               int ma_shift, int ma_method, int applied_price, 
               int shift)

Calculates the Standard Deviation 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.
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.  
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=iStdDev(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,0);

iStdDevOnArray()

double iStdDevOnArray(double array[], int total, int ma_period, 
                      int ma_shift, int ma_method, int shift)

Calculation of the Standard Deviation indicator on data stored in a numeric array. Unlike iStdDev(…), the iStdDevOnArray 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 whole array. 
ma_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. 
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=iStdDevOnArray(ExtBuffer,100,10,0,MODE_EMA,0);

iStochastic()

double iStochastic(string symbol, int timeframe, 
                   int %Kperiod, int %Dperiod, int slowing, 
                   int method, int price_field, 
                   int mode, int shift)

Calculates the Stochastic 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. 
%Kperiod    - %K line period. 
%Dperiod    - %D line period. 
slowing     - Slowing value. 
method      - MA method. It can be any of the Moving Average method enumeration value. 
price_field - Price field parameter. Can be one of this values: 0 - Low/High or 1 - Close/Close 
mdoe        - 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( iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,0)
     >iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,0)) 
   return(0);

iWPR()

double iWPR(string symbol, int timeframe, int period, int shift)

Calculates the Larry William’s percent range 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:

  if(iWPR(NULL,0,14,0)>iWPR(NULL,0,14,1)) return(0);
This article url: http://www.myeatrade.com/455/

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