Download MetaTrader 5


The function returns the handle of a specified technical indicator created based on the array of parameters of MqlParam type.

int  IndicatorCreate(
   string           symbol,                            // symbol name
   ENUM_TIMEFRAMES  period,                            // timeframe
   ENUM_INDICATOR   indicator_type,                    // indicator type from the enumeration ENUM_INDICATOR
   int              parameters_cnt=0,                  // number of parameters
   const MqlParam&  parameters_array[]=NULL,           // array of parameters



[in] Name of a symbol, on data of which the indicator is calculated. NULL means the current symbol.


[in]  The value of the timeframe can be one of values of the ENUM_TIMEFRAMES enumeration, 0 means the current timeframe.


[in]  Indicator type, can be one of values of the ENUM_INDICATOR enumeration.


[in] The number of parameters passed in the parameters_array[] array. The array elements have a special structure type MqlParam. By default, zero - parameters are not passed. If you specify a non-zero number of parameters, the parameter parameters_array is obligatory. You can pass no more than 256 parameters.


[in]  An array of MqlParam type, whose elements contain the type and value of each input parameter of a technical indicator.

Return Value

Returns the handle of a specified technical indicator,  in case of failure returns INVALID_HANDLE.


If the indicator handle of IND_CUSTOM type is created, the type field of the first element of the array of input parameters parameters_array must have the TYPE_STRING value of the ENUM_DATATYPE enumeration, and the string_value field of the first element must contain the name of the custom indicator. The custom indicator must be compiled (file with EX5 extension) and located in the directory MQL5/Indicators of the client terminal or in a subdirectory.

Indicators that require testing are defined automatically from the call of the iCustom() function, if the corresponding parameter is set through a constant string. For all other cases (use of the IndicatorCreate() function or use of a non-constant string in the parameter that sets the indicator name) the property #property tester_indicator is required:

#property tester_indicator "indicator_name.ex5"

If the first form of the call is used in a custom indicator, you can additionally indicate as the last parameter on what data it will be calculated when passing input parameters. If the "Apply to" parameter is not specified explicitly, the default calculation is based on the PRICE_CLOSE values.


void OnStart()
   MqlParam params[];
   int      h_MA,h_MACD;
//--- set ma_period
   params[0].type         =TYPE_INT;
//--- set ma_shift
   params[1].type         =TYPE_INT;
//--- set ma_method
   params[2].type         =TYPE_INT;
//--- set applied_price
   params[3].type         =TYPE_INT;
//--- create MA
//--- create iMACD("EURUSD",PERIOD_M15,12,26,9,h_MA);
//--- set fast ma_period
   params[0].type         =TYPE_INT;
//--- set slow ma_period
   params[1].type         =TYPE_INT;
//--- set smooth period for difference
   params[2].type         =TYPE_INT;
//--- set indicator handle as applied_price
   params[3].type         =TYPE_INT;
//--- create MACD based on moving average
//--- use indicators
//--- . . .
//--- release indicators (first h_MACD)

Updated: 2015.12.03