MetaEditor Help

Creating Indicators

Creating Indicators

An indicator template is a file designed for writing a source code. After it has been created, it is automatically placed in MQL5/Indicators (or MQL4/Indicators) directory. During the creation a user can select event handlers that will be added to the template.

After choosing the corresponding position in the MQL4/MQL5 Wizard and pressing the "Next" button the following window appears:

Creation of Indicator

The following fields should be filled out in this window:

  • Name — the name of the custom indicator, the same name will be given to its file;
  • Author — the name of the author;
  • Link — the e-mail or website address of the developer;
  • Parameters — a set of input parameters (external variables) of the custom indicator.

Variables of the "input" class refer to external parameters. In order to create a parameter one should press the "Add" button. There are three fields that should be filled out at the appeared entry:

  • Name — the name of the input variable;
  • Type — the type of the input variable that is chosen from the list;
  • Initial Value — the initial value of the variable that will be used on default before it is changed manually.

Event Handlers

At this step you can select additional event handlers that will be inserted into the indicator template. All the necessary parameters will also be specified for the selected handlers; it's helpful for programmers.

Select Event Handlers

To select one or more event handlers put a checkmark against them. Here you can also chose a type of the OnCalculate() handler, which will be added to the template. If you hold the mouse cursor over a handler name, a pop-up help containing extended description of the handler will be shown.

Selected handlers are added in addition to the main ones — OnInit(), OnCalculate().

To go to the next step, press the "Next" button.

Drawing Properties

Creation of Indicator

At this stage one should specify the following parameters:

  • Indicator in separate window — this option allows to predefine whether the indicator will be drawn in its own separate subwindow or it will be attached to the main chart window;
  • Minimum — if the option of drawing the indicator in a separate window is enabled then in this field one can specify the lower limit of the vertical scale of values for the window;
  • Maximum — if the option of drawing the indicator in a separate window is enabled then in this field one can specify the upper limit of the vertical scale of values for the window;
  • Plots — the types of representation of indicator's data are specified in this box. In other words, what exactly will be drawn by the indicator is chosen here.

In order to add a line to the "Plots" box one should press the "Add" button. In the appeared line it is necessary to specify the name, type and color. The type is selected from the dropdown list. Each of the variants chosen means the automatic creation of necessary minimum of parameters and arrays for drawing. As soon as the "Done" button is pressed, the project of the custom indicator will be created and the window for writing its source code will be opened automatically.