Examples of problem solving with the help of indicators Universal

14 September 2018, 14:46
Yurij Kozhevnikov
0
295

RU

Examples of real user requests for writing an indicator and solving their problems with the help of indicators Universal

Contents


Question 1. Exceeding the value.

Write, please, such an indicator - it is necessary to graphically, from a vertical line, to show those candles on which the indication of the RSI exceeds by me the specified certain value. These values ​​(levels of RSI) can vary from 0 to 100 and it is important that you can enter four decimal places, for example the value 79.9834. 

  In the indicator settings, it was necessary to change the period of the RSI and enter the level of the RSI at which vertical lines appear through the candle.

  Well, for example, the period of the RSI 2 and let's say I entered to post a higher level of 86.8840 through these candles, a vertical line was drawn.

Answer

The indicators Universal are not designed to draw additional graphic objects, but you can achieve similar effects using a single indicator line.
We solve the problem formulated in the last sentence.
To control the RSI indicator with a period of 2 on the chart, we add a level with a value of 86.8840 for the control.
Then, turn the indicator Universal Main Window or Universal Main Window MT5 on the chart, depending on the platform and write the formula:

IF (RSI(2, 0 , 0) > 86.8840, 1.01 * High(0), 0)

In other words, we draw a line according to the following rule:
If the RSI value is greater than 86.8840, then the indicator value is higher than the current bar maximum by 1%. Otherwise - zero.

As you can see, the result is very similar to what the user requested.

Contents

Question 2. Modification of the indicator Envelopes.

Hello, please help!

 It is necessary that the indicator Envelopes.mq5 deviation was taken not in percentage (%), but in points based on the calculation of the indicator ATR.mq5. Thank you in advance)

Answer

From the help we learn how the Envelopes indicator is calculated.
It turns out that this is indicator Moving Average, shifted up and down by a specified percentage. In order to simulate the operation of this indicator, replacing the percentages with the items taken from the indicator ATR, two copies of the free version of the indicator Universal Main Window Free or Universal Main Window Free MT5 will suffice, depending on the platform.
Turn on the chart indicators ATR and Envelopes, indicating the settings the same period.
We throw the first indicator Universal, on the chart for the upper line, assigning it the color of the Aqua line and the following formula:

MA(14, 0, 0, 0) + ATR(14, 0)

For the bottom line, assign the color of Magenta and the formula:

MA(14, 0, 0, 0) - ATR(14, 0)

As you can see, the result is not much different from the standard indicator Envelopes.

Contents

Question 3. Intersections.

Hello. Help with the indicator light. I can not find a working variant anywhere.

The principle of operation is as follows: if the price crosses the upper or lower Bollinger band with standard settings, and at the same time, the designated RSI indicator aisles (70-30 or 80-20), the indicator should beep. You can add a pointer to this indicator. The RSI period must be user-configurable. Thank you in advance.

and RSI and BB intersection from top to bottom of the top line or from bottom to top, describe conditions more precisely
in general, the system is based on the attenuation of the trend. if the price crosses the upper border BB from the bottom up and the border is 70 or 80 RSI, then a sell signal is given, if the price crosses the lower BB limit from the top down and the border is 30 or 20 RSI, then a buzzer is given. Bollinger bands with standard settings period 20, deviation 2, RSI should be customized by the user, including the extreme chapters. timeframe 1, 5, 15, 30 minutes.

Answer

Intersections are a subtle question that can be understood and implemented in different ways. Simultaneous intersections in two different indicators are very rare, which can never happen at all. Some customers incorrectly use the term "intersection", meaning by it "location in the area".
We consider the implementation of both concepts.
The final implementation will be common: in an separate chart window the indicator will draw a line in the range from -2 to +2, where the values ​​-2 and +2 will mean compliance with both conditions for sale or purchase, respectively, -1 and +1 - compliance with only one condition , and 0 - non-observance of any conditions or receipt of multidirectional signals.
Since our algorithm has conditions, we need a full version of the indicator Universal Separate Window or Universal Separate Window MT5, depending on the platform.

1. Intersection.
We will understand the concept of intersection and divide the problem into components.
Take the imaginary Line1 and Line2. Suppose that Line1 on the previous bar was below Line2, and on the current bar - higher. How can this be expressed in terms of formulas? If you recall that the current bar is always zero, the previous one, and so on, you can tell that Line1(1) < Line2(1) And Line1(0) > Line2(0). Is this sufficient condition? No. Rarely, but sometimes it can happen that we get to the moment of crossing and then Line1 = Line2. You can try to make such a condition: Line1(1) <= Line2(1) And Line1(0) > Line2(0). But in this case we can get a false alarm if Line1 was above Line2, touched it at the next bar, and then rose again. There will not be an intersection in this case, but the condition will work. We assume that this check is sufficient: on the second bar, Line1 is below Line2, on the first bar, below or at one level, and at zero above: Line1(2) < Line2(2) And Line1(1) <= Line2(1) And Line1(0) > Line2(0).
Now let's move on to the indicators.

1.1. Bollinger Bands®.
Let's make the condition of intersection by the price of the top line of the indicator with the settings set in the question and assign it to the field Expression1:

Expression1 =
AND( Close(2) < BB(20,2,0,1,2) , Close(1) <= BB(20,2,0,1,1) , Close(0) > BB(20,2,0,1,0))

Similarly, we formulate the condition for the intersection of the bottom line and assign it to the field Expression2:

Expression2 =
AND( Close(2) > BB(20,2,0,2,2) , Close(1) >= BB(20,2,0,2,1) , Close(0) < BB(20,2,0,2,0))

Recall that the intersection of the upper line - this signal for sale, and the intersection of the bottom - a signal to buy.
Let us formulate the general condition:
If the signal to sell, then -1, otherwise if the signal to buy, then +1, otherwise 0.
Let's create the appropriate formula by inserting the conditions created in it, and assign it to the Expression3 field:

Expression3 =
IF ( Expression1 , -1 , IF ( Expression2 , 1 , 0 ) )

1.2. Relative Strength Index.
Let us also formulate the condition for crossing the line of the indicator RSI from the bottom upwards to the value 70. Since the volatility of the line increases with decreasing period, set the period to 5. Assign this condition to the field Expression4:

Expression4 =
AND( RSI(5,0,2) < 70 , RSI(5,0,1) <= 70 , RSI(5,0,0) > 70)
Now the condition for the intersection of the top-down value of 30 is assigned to the field Expression5:
Expression5 =
AND( RSI(5,0,2) > 30 , RSI(5,0,1) >= 30 , RSI(5,0,0) < 30)

And now with the help of these blanks we will compose the general formula as for the previous indicator and assign it to the field Expression6:

Expression6 =
IF ( Expression4 , -1 , IF ( Expression5 , 1 , 0 ) )

1.3. The final formula.
We have obtained two formulas for the two indicators, which, when signaled for sell, return -1, and with a signal for the buy of +1.
Summarize them and get the final formula that we insert in the Line Function field:

Line Function =
Expression3 + Expression6

1.4. Result.

2. Location in the area.
To check the condition of finding a line in a certain region, one is enough (if the line must be above or below a certain value) or two (if the line must be between two definite values) conditions.
In our case, one condition for each test is sufficient.
Let's write these conditions as in the previous example.

2.1. Bollinger Bands®.
Let's make the condition of finding a price above the upper line of the indicator and assign it to the field Expression1:

Expression1 =
Close(0) > BB(20,2,0,1,0)

Now let's make a condition for finding the price below the lower line and assign it to the Expression2 field:

Expression2 =
Close(0) < BB(20,2,0,2,0)

Thanks to this structure, the general formula for the indicator will not differ from the previous example:

Expression3 =
IF ( Expression1 , -1 , IF ( Expression2 , 1 , 0 ) )

2.2. Relative Strength Index.
Similarly, we formulate the conditions for the indicator RSI:

Expression4 =
RSI(5,0,0) > 70
Expression5 =
RSI(5,0,0) < 30
Expression6 =
IF ( Expression4 , -1 , IF ( Expression5 , 1 , 0 ) )

2.3. The final formula.
The final formula also does not differ from the previous example:

Line Function =
Expression3 + Expression6

2.4. Result.

Important note. It should be remembered that for zero, that is, the current bar Close(0) is always the price at the current time. This applies to the values of the indicators. Over time, they change and can then show the signals of interest to us, then do not show. You can avoid this by moving all the checks one bar back. In this case, our indicator will not redraw the value on the current bar.

Contents

Question 4. Size of the candle.

Is there an indicator that showed the volume of the body of the candle in the points on the chart?

Answer

In order to know the magnitude of any component of the candle, you need to subtract one bar from the other. In order for the result to be in points, the difference should be multiplied by 10 to the power of the number of decimal places in the price of this instrument. For this task, a free indicator Universal Separate Window Free or Universal Separate Window Free MT5 will be sufficient, depending on the platform.
Let's create a table in which we will determine all possible candle properties for a five-digit:

Size of the candle
(High(0) - Low(0)) * 10^5
Body size candles
Abs(Close(0) - Open(0)) * 10^5
The size of the upper shadow
( High(0) - Max( Open(0), Close(0) ) ) * 10^5
The size of the lower shadow
( Min (Open(0), Close(0) ) - Low(0) ) * 10^5

Body size candles:

Contents



Share it with friends: