Thursday, May 26, 2011

Structure of indicator

Structure of indicator

As stated above, instead of defined in section entrances indicators exist, the code indicator starts with it. In general, the first go "cap" of the indicator, but we will consider in the next part of the lesson.
Inputs: Period (21) Bars (500) / / External variables
Var: after (0), shift (0) / / internal variables

/ / In addition there is a source of indicator

MetaEditor automatically create a kind of code:
SetLoopCount (0);
/ / Loop from the first bar of the current bar (with shift = 0)
For shift = Bars Downto-1 0 Start
SetIndexValue (shift, 0);
End;

This means that the indicator will be drawn from early history to the end, it is possible to use as a species:
For shift = 0 and Bars-1 Start
SetIndexValue (shift, 0);
End;

So the indicator will be drawn from the end of history, that of the current bar and come to the end of last year. What method you choose to solve for you, but you seem to remember that complex user indicators, and braking hard work MT and, consequently, the indicators do not appear throughout history. In this case it is better prepared than last indicator (current) bar. As you have already of course, loading a file is performed by a cycle in this case the cycle.

Function SetIndexValue (shift, 0) in the full file indicator for each bar. Shift is a mobile file indicator (one cell is a bar), 0 is the value that will be taken away. The files can be two, so for the second function file looks like this:

SetIndexValue2 (shift, 0).

The indicator, which will form the channel between the maximum and floor prices (H and L):
/ * [[
Name: H =- l
Author: = fxtest.ru
Link: = forextimes.ru
Separate Window: = No
First Color: Blue =
First Draw Type: = Line
First Symbol: = 217
Use Second Data: = Yes
Second Color: Red =
Second Draw Type: = Line
Second Symbol: = 218
]] * /

Variable: shift (0);

For shift = 0 and Bars-1 Start
SetIndexValue (shift, h [shift]);
SetIndexValue2 (shift, l [shift]);
End;

Most often it happens, it is necessary to use the value of the indicator in the past. For this purpose, function GetIndexValue (shift), where the shift - the number of mobile file indicator is used. Function GetIndexValue that may seem GetIndexValue2.

No comments:

Post a Comment

Powered by Blogger.