How do I find the times of the maxima and minima?

John Prngle

New member
Joined
Aug 26, 2021
Messages
5
I need to determine the time some events happened. The events are maximum and minimum values.

I want to be able to ask each data point along the way and say, are you a maxima or minima? and if it says yes then I add it to a list. Then when I find two, I want to ask if it is higher or lower then the one before which I can do this part, it's just finding where they are which is a problem for me.

Screenshot_20210826-193405_MetaTrader 4.jpg
 
I am sorry but I have no idea what you are talking about.

You have a number of data points over time and a red line that obviously does not approximate the location of minima and maxima as a function of time. What is the red line and how did you derive it? What is it supposed to represent? Do you know about degrees of freedom?

“It’s just finding where they are” is a rather obscure question. Maybe a site on problems in ontology can help
 
I need to determine the time some events happened. The events are maximum and minimum values.

I want to be able to ask each data point along the way and say, are you a maxima or minima? and if it says yes then I add it to a list. Then when I find two, I want to ask if it is higher or lower then the one before which I can do this part, it's just finding where they are which is a problem for me.

View attachment 28661
One data point doesn't know whether it is a maximum or minimum (unless it's much smarter than most data points I know). At the least, it will have to ask its neighbors.

Can you tell us more about what you are really doing? (That is, how do you "ask"? And what form does a data point take?)
 
I am sorry but I have no idea what you are talking about.

You have a number of data points over time and a red line that obviously does not approximate the location of minima and maxima as a function of time. What is the red line and how did you derive it? What is it supposed to represent? Do you know about degrees of freedom?

“It’s just finding where they are” is a rather obscure question. Maybe a site on problems in ontology can help
The white bars come from a formula to show how strong momentum is in each direction on a straight line. The red line is a moving average of the momentum. This is used as an approximation of when momentum changes direction. However, being able to see the maxima as it unfolds would mean I wouldn't need to wait for the moving average to catch up.
 
One data point doesn't know whether it is a maximum or minimum (unless it's much smarter than most data points I know). At the least, it will have to ask its neighbors.

Can you tell us more about what you are really doing? (That is, how do you "ask"? And what form does a data point take?)
The data points themselves are not very smart but a computer program able to create a list of data points for iteration can be. I know what values come before and after the data point I want to poll and I could just find out if both sides are smaller than the one in question but that would produce the occasional false signal whereas I believe it should be possible using a formula to find where the larger curves in the data are while eliminating the smaller ones which produce false signals. Perhaps what I am looking for is not possible and if not then I can just attempt to look ate 5 data points; the one in question and the 2 either side of it and compare them which would produce less false signals.
 
One data point doesn't know whether it is a maximum or minimum (unless it's much smarter than most data points I know). At the least, it will have to ask its neighbors.

Can you tell us more about what you are really doing? (That is, how do you "ask"? And what form does a data point take?)
For more detail on what I am trying to accomplish. I have created a program which takes trades in real time based on certain signals. I will provide a real example here...

maths.PNG

The green dots are buy signals and the red dots are sell signals. You may decide to buy when you receive a green signal below zero on both the lower indicator and a complimentary green signal on the upper price chart at approximately the same time. However, they are late because the blue line on the lower indicator changes direction before its moving average does so it takes them time to cross.

The latest signal on the upper price chart (also caused by a moving average crossing something else) is also late as it appears at the time when that "candle" is finished. The buy trade happened at the top of it when it would have been nice if the signal was on one of the few candles before this.

As both sets of values move in waves, they form minima and maxima along the way and I thought there would be a way to determine this with a formula. Perhaps the formula could return 1 for a maxima, -1 for a minima or zero for neither. The formula could be capable of taking multiple unknown variables; a, b, c, d and e where c is the data point in question and a, b, d and e are the data points either side.

My math isn't great but I'm ok with algebra and perhaps if I also learn trigonometry I could draw some tangents and chords on a circle to help me figure all this out but I have no idea if trigonometry is the right way to figure it out or whether I need calculus. I just need something to be better than the moving average methods as they are lagging.
 
The data points themselves are not very smart but a computer program able to create a list of data points for iteration can be. I know what values come before and after the data point I want to poll and I could just find out if both sides are smaller than the one in question but that would produce the occasional false signal whereas I believe it should be possible using a formula to find where the larger curves in the data are while eliminating the smaller ones which produce false signals. Perhaps what I am looking for is not possible and if not then I can just attempt to look at 5 data points; the one in question and the 2 either side of it and compare them which would produce less false signals.
Prevention of false signals is part of what the moving average is for! The only way to avoid them is to wait for confirmation by subsequent data. If you want to immediately know whether you have reached a peak, you will need to be psychic. (A lot of stock traders would like that skill.)

Yes, if you look at 5 points rather then 3, you will have fewer false signals (and that will be better in some sense than the moving average); but there will still be some, depending on how you are defining a maximum. You have to decide on the tradeoff between errors and speed.

The serious point behind my joke about smart data points is that you need to look beyond one data point; and the farther you look, the more certain you can be.
 
This is not a mathematical answer.

I am very dubious about the economics behind “charting.” However, your red graph does seem to recognize downturns and upturns with a decent frequency of success. True, it will always be late, but in many cases, it does seem that the indicated turning point in the red curve is followed by a number of days of continued movement of momentum in the same direction. However, if I understand what you are saying, you have not matched your red line against actual prices. Whether it makes any sense to base a trading strategy on your red curve would depend on a comparison against opening prices two days after a change in direction of the red curve over a much longer period than you have shown.
 
This is not a mathematical answer.

I am very dubious about the economics behind “charting.” However, your red graph does seem to recognize downturns and upturns with a decent frequency of success. True, it will always be late, but in many cases, it does seem that the indicated turning point in the red curve is followed by a number of days of continued movement of momentum in the same direction. However, if I understand what you are saying, you have not matched your red line against actual prices. Whether it makes any sense to base a trading strategy on your red curve would depend on a comparison against opening prices two days after a change in direction of the red curve over a much longer period than you have shown.
The blue line on the lower indicator is created by taking two exponential moving averages and measuring the distance between them at any point in time. When a 12 period moving average crosses a 26 period moving average, the indicator's blue line crosses zero. The red line smooths the signal with a 9 period simple moving average. Looking at the most recent two minima on the red line, they run parallel with the two equivalent minima in price. If they were to be converging or diverging, that would indicate a correct signal. Therefore, the trade taken by this system is wrong. I need to find the last two maxima and minima occurred and find out their relative magnitudes so I can filter out the bad trades such as this one.
 
Top