MQL4参考 自定义指标
Custom IndicatorsThis is the group functions used in the creation of custom indicators. These functions can't be used when writing Expert Advisors and Scripts.
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 MQL5MQL4 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. |