Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 358

 

Hello!

1. Can you tell me if it is possible, in principle, to write code, if the condition for opening an order is the crossing of two indicators, which are opened in a separate window (not on the chart). BUT ... One has a value curve from -100 to 0 and the other from -1.3 to 1.3 ????

2. If it is possible, which function to use ( which direction to go, learn MQL4) ????

 
bergkamp.:

there's more to it than that - a straight line could be 20 bars, let it be 30 for an example

The signal is either at segment C or D (at D when C is formed - immediately - at the first bar of segment D)

I wonder. Do you need an algorithm, or do I need to write an indicator here?

You do not just decide what you need, but what do I need? I have given you a lot of pointers. There are a lot of pitfalls there, too. The algorithm will find the maximum difference between the line drawn through the end points of the curved segment of the MAW and the maximum value of the MAW within the specified interval.

This will not work for the indicator - it will find any non-zero divergence and only say where on this segment and in which direction the MA is bent. There may be more than one such bend within a given distance. Then what to do?

The algorithm is as follows: draw a virtual line between the given line segment ends and look for the maximum deviation from the value of the virtual line. If the past value is less than the current one, we memorize the value and bar. After the cycle we have the maximum deviation and the bar at which it is registered.

This is just the direction of the search that first came to me. I'm sure there are much less resource intensive algorithms. That should go to the indicator people. I'm mainly into EAs.

 
Scomoroh:

Hello!

1. Can you tell me if it is possible, in principle, to write code, if the condition for opening an order is the crossing of two indicators, which are opened in a separate window (not on the chart). BUT ... One has a value curve from -100 to 0 and the other from -1.3 to 1.3 ????

2. If it is possible, which function to use ( which direction to go, study MQL4) ????

You may change the vertical scale back and forth, and, oops... Here they have crossed, and now they haven't.

First they have to be put into the same frame of reference. But they will not be the same indicators at all

 
bergkamp.:

there's a bit more to it than that - a straight line can be 20 bars, let it be 30 for example

the signal either on the segment C or D ( on D when C is formed - immediately - on the first bar of the segment D ) or better on the first bar of the segment C


you need to find the change of direction ? ( rising --- falling ) first derivative == 0

or is it a curve ??? ( growth as square root --- growth as parabola) second derivative == 0

 
artmedia70:

And you change the vertical scale back and forth and, oh... they've crossed over, and now they haven't.

First you have to put them in the same reference frame. But it will not be the same indicators at all


So in principle it's possible????

How to bring them into one reference frame, you have to rewrite their code, make changes?

 
ALXIMIKS:


you need to find 1 point of change in direction? ( rising --- falling ) first derivative == 0

or 2 the curvature ? ?? ( growth as square root --- growth as parabola) second derivative == 0

this is very interesting, could you share the code for an example and

1 - this will be the signal up / down - better on the first bar of segment C

2 - if there is no bend, the current direction of motion will not change - which is logical.

 
artmedia70:

Here's an interesting one. Do you need an algorithm, or do I need to write an indicator here?

You don't just decide what you need, do I? I've given you a good idea. There are a lot of pitfalls there, too. The algorithm will find the maximum difference between the line drawn through the end points of the curved segment of the MAW and the maximum value of the MAW within the specified interval.

This will not work for the indicator - it will find any non-zero divergence and only say where on this segment and in which direction the MA is bent. There may be more than one such bend within a given distance. Then what to do?

The algorithm is as follows: draw a virtual line between the given line segment ends and look for the maximum deviation from the value of the virtual line. If the past value is less than the current one, we memorize the value and bar. After the loop we have the maximum deviation and the bar at which it is registered.

This is only a direction of search that came to me in the first place. I'm sure there are much less resource intensive algorithms. This should go to the indicator people. I'm mainly into EAs.

Thank you, the idea is very much in favour, but how would it be implemented in code ? the very piece of finding such moments
 

the code for defining the red dot in the article - has already directed you once -

может быть полезно https://www.mql5.com/ru/articles/1569 all variants of events are provided for

3.3. tops and troughs

 
artmedia70:

The algorithm is as follows: draw a virtual line between the given ends of the MAH segment and search for the maximum deviation of the MAH value from the value of the virtual line. If past value is less than current one, we memorize the value and bar. After the loop we have the maximum deviation and the bar at which it is registered.

This is only a direction of search that came to me in the first place. I'm sure there are much less resource intensive algorithms. This should go to the indicator people. I'm mainly into EAs.


Interesting thoughts on the indicator. I've been trying to make something similar for a couple of months. The main problem is that when I put the indicator on the chart it shows what it should. When I run it in the tester, it does not show what I want. I try to record a value and compare it on a new bar, if a certain value is passed, we write the current value to the buffer, in the other case, the value remains the same (as written). But in the tester the indicator still performs changes when it hasn't reached this certain value and should not change. I have tried a lot of options, but so far I have not found a solution to the problem.
 
bergkamp.:

there is more to it than that - a straight segment can be 20 bars, let it be 30 for example

the signal is either on the segment C or D (on D when C is formed - immediately on the first bar of the segment D) or better on the first bar of the segment C


IndexMaMax = ArrayMaximum( ArrayMa,30,1) look for the maximum of 30 bars

IndexMaMin = ArrayMinimum( ArrayMa,30, 1) search for the minimum for 30 bars

ArrayMa[1] < ArrayMa[IndexMaMax]

ArrayMa[1] > ArrayMa[IndexMaMin] went up


Reason: