MQL4 Reference Custom Indicators

Custom Indicators

This is the group functions used in the creation of custom indicators. These functions can't be used when writing Expert Advisors and Scripts.




The function sets a flag hiding indicators called by the Expert Advisor


Sets the value of an indicator property of the double type


Sets the value of an indicator property of the int type


Sets the value of an indicator property of the string type


Binds the specified indicator buffer with one-dimensional dynamic array of the double type


Allocates memory for buffers used for custom indicator calculations


Returns the amount of bars not changed after the indicator had been launched last


Sets precision format to visualize indicator values


Sets the "short" name of a custom indicator to be shown in the DataWindow and in the chart subwindow


Sets an arrow symbol for indicators line of the DRAW_ARROW type


Sets the bar number from which the drawing of the given indicator line must start


Sets drawing line empty value


Sets drawing line description for showing in the DataWindow and in the tooltip


Sets offset for the drawing line


Sets the new type, style, width and color for a given indicator line


Sets a new style, width and color of horizontal levels of indicator to be output in a separate window


Sets a value for a given horizontal level of the indicator to be output in a separate window

Indicator properties can be set using the compiler directives or using functions. To better understand this, it is recommended that you study indicator styles in examples.

All the necessary calculations of a custom indicator must be placed in the predetermined function OnCalculate().


What's new in MQL5

MQL4 programmers have 8 buffers and 6 drawing styles to develop custom indicators. In MQL5, this set has been significantly increased up to 512 indicator buffers and 18 drawing styles. In addition, timeseries indexing (calculation from present to past) is not necessary to calculate indicator values. Such an approach is very convenient for developing EAs, but it causes difficulties when working with indicator buffers in loops. Now you are able to set the indexing direction in the arrays on your own, which greatly simplifies the development of indicators.

Another notable feature of MQL5 is the dynamic change of the drawing style using the PlotIndexSetXXX functions. For example, an indicator's color, style, line width, as well as an arrow's color and code can be changed on the fly if a certain condition occurs.


Also, added the OnCalculate() handler allowing to calculate indicator values based on another indicator. Thus, in MQL5, custom indicators can be superimposed on other indicators (for example, TEMA from MACD) allowing users to receive new combinations of indicators to quickly test ideas without programming.