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

 
bergkamp.:

picture for example ...

help with code condition .........................................


ma[1]>ma[2] upwards

ma[1]<ma[2] down

 
bergkamp.:

picture for example ...

help with code condition ...................................................................................

A bend is an extremum. It has three points A, B and C. To determine that point B is the centre of the bend (extremum), you have to resort to this formula:

if ((А-В)*(В-С)<0) { // Если экстремум
   if (B<C) {
      // код для обработки нижнего экстремума
      }
   if (B>C) {
      // код для обработки верхнего экстремума
      }
   }


Since it is better not to use zero bars to avoid false signals, A is the MAA data on bar 3, B on bar 2 and C on bar 1

 
bergkamp.:

picture for example ...

help with the code condition ...................................................................................

can be useful https://www.mql5.com/ru/articles/1569 all options are envisaged

3.3. tops and troughs

 

pako: спасибо

ALXIMIKS: very useful, thank you .
artmedia70: thank you, but in order

The bend is an extremum. It has three points A, B and C. In order to determine that point B is the centre of the bend(extremum), we have to resort to this formula:

As it is better not to use zero bar to avoid false signals, A is MA data on the 3rd bar, B on the second and C on the first

 1 - что в этой строчке должно быть ? индикатор MA !!!  и как бы в буквах A ,B , и  C
// код для обработки нижнего экстремума

2 there is one trick !!! - A bend is an extremum - I agree, but it's not an extremum as if it were a fractal - i.e. to take into account only the last 3 bars that formed it,

this segment and segments may contain more than one bar - let me schematically represent it

the bar segments may contain several bars (sometimes 15 bars) and calculation of 3 bars (and in general, reference to the bars should not be done - imho - I could be wrong) is not good

how to catch the transition from A to C with the top of B in the code ...

 
bergkamp.:

2 there is one trick !!! - A bend is an extremum - I agree, but it is not an extremum as if it were a bar!!! you cannot represent it as a fractal - i.e. only the last 3 segments that formed will be taken into account,

this segment and segments may contain more than one bar - let me schematically represent it

the bar segments may contain several bars (sometimes 15 bars) and calculation of 3 bars (and in general, reference to the bars should not be done - imho - I could be wrong) is not good

how to catch the transition from A to C with the top of B in the code ...

How can we tell with our eyes that there is a curve bent somewhere?
Probably, our eye simply picks out the segment we need from the line, then uses its extreme points (left and right) to determine the largest/lowest deviation from the tangent through the values of these extreme points. The anticipated extremum is located at the point of the largest deviation.

Maybe this algorithm will work?

 
artmedia70:

How can we tell with our eyes that there is a curve bent somewhere?
Probably, our eye simply picks out the segment we need from the line, then uses its extreme points (left and right) to determine the largest/lowest deviation from the average value of these extreme points. Where the greatest deviation is the expected extremum.

Would this algorithm work?

I hope you can give us an example, maybe you can do it with the code, thank you.
 
bergkamp.:
I hope you can give me an example, maybe it will work, with the code, thank you.

I corrected myself there - not the average, but the tangent. I'm afraid the algorithm will be slow for an indicator.

With the code. The questions here are:

1. the required length of the segment - I don't know it, nor do I know the beginning and end of this segment.

2. I don't know at all what it's all about in order to use it.

 
artmedia70:

I corrected myself there - not the average, but the tangent. I'm afraid the algorithm will be slow for an indicator.

With the code. The questions here are:

1. the required length of the segment - I don't know it, nor do I know the beginning and end of this segment.

2. I don't know at all what it all needs to be used for.



1, the indicator - MA - is a dummy with no frills - that's what it draws the lines,

2, when there is a bend - we need a simple signal up / down - ALL !!! The signal is either on the segment C or D ( on D when C is formed - immediately)

 
bergkamp.:


1, the indicator is a MA - no trick - so it draws the lines,

2, when there is a bend - a simple up/down signal is needed - ALL !!!

Very funny.

1. MA over how many bars?

2. If there is a bend, is the signal on the bend? Or on the zero bar?

 
artmedia70:

Very funny.

1. MA for how many bars?

2. If there is a bend, is the signal on the bend? Or at the zero bar?


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

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