I've been performing some research, in order to find the best approach to identify break points (trend direction change) in a dataset (with pairs of x/y coordinates), that allow me to identify the trend lines behind my data collections.
However I had no luck, finding anything that brings me some light.
The yellow dots in the following image, represent the breakpoints I need to detect.
Any suggestion about an article, algorithm, or implementation example (typescript prefered) would be very helpful and appreciated.
I've been performing some research, in order to find the best approach to identify break points (trend direction change) in a dataset (with pairs of x/y coordinates), that allow me to identify the trend lines behind my data collections.
However I had no luck, finding anything that brings me some light.
The yellow dots in the following image, represent the breakpoints I need to detect.
Any suggestion about an article, algorithm, or implementation example (typescript prefered) would be very helpful and appreciated.
Share Improve this question edited Jun 15, 2020 at 18:53 Emma 27.8k11 gold badges48 silver badges71 bronze badges asked Jun 7, 2020 at 17:16 colxicolxi 8,7503 gold badges47 silver badges44 bronze badges 4- 1 You may be able to formulate this as a polynomial approximation problem (find curve to "fit" your data) stackoverflow./questions/28269021/…. Then you can find local minima and maximas of that curve to determine the breakpoints. – cisco Commented Jun 10, 2020 at 7:08
- 1 there are many ways to do it like sign of sliding average derivation change, angle between last breakpoint and 2 consequent poitns change thresholding, intersection of regresed lines, ... – Spektre Commented Jun 11, 2020 at 5:03
- It will always be a lagging indicator. Prices will need to move past the breakpoint in order to identify it as a breakpoint. If you want to implement a leading one, you will have to optimize it and deal with probabilities. – Youssef Egla Commented Jun 16, 2020 at 19:39
- Just search leading and lagging indicators. you'll find plenty – Youssef Egla Commented Jun 16, 2020 at 19:39
3 Answers
Reset to default 4 +100Usually, people tend to filter the data by looking only maximums (support) or only minimums (resistance). A trend line could be the average of those. The breakpoints are when the data crosses the trend, but this gives a lot of false breakpoints. Because images are better than words, you can look at page 2 of http://www.meacse/ijcar/archives/128.pdf.
There are a lot of scripts available look for "ZigZag" in
https://www.tradingview./
e.g. https://www.tradingview./script/lj8djt1n-ZigZag/ https://www.tradingview./script/prH14cfo-Trend-Direction-Helper-ZigZag-and-S-R-and-HH-LL-labels/
Also you can find an interesting blog post here (but code in in python):
https://towardsdatascience./programmatic-identification-of-support-resistance-trend-lines-with-python-d797a4a90530
with code available: https://pypi/project/trendln/
If you can identify trend lines then can't you just identify a breakpoint as when the slope changes? If you can't identify trend lines, then can you for example, take a 5-day moving average and see when that changes slope?
This might sound strange, or even controversial, but -- there are no "breakpoints". Even looking at your image, the fourth breakpoint might as well be on the local maximum immediately before its current position. So, different people might call "breakpoints" different points on the same graph (and, indeed, they do).
What you have in the numbers are several possible moving averages (calculated on a varying interval, so you might consider MA5 for five-day average, or MA7 for a week average) and their first and maybe second derivatives (if you feel fancy you can experiment with third derivatives). If you plot all these lines, suitably smoothed, over your data, you will notice that the salient points of some of them will roughly intersect near the "breakpoints". Those are the parameters that your brain considers when you "see" the breakpoints; it is why you see there the breakpoints, and not somewhere else.
Another method that the human vision employs to recognize features is trimming outliers: you discard in the above calculations either any value outside a given tolerance, or a fixed percentage of all values starting from those farther from the average. You can also experiment not trimming those values that are outliers for longer-period moving averages but are not for shorter periods (this gives better responsivity but will find more "breakpoints"). Then you run the same calculations on the remaining data.
Finally you can attribute a "breakpoint score" based on weighing the distance from nearby salient points. Then, choose a desired breakpoint distance and call "breakpoint" the highest scoring point in that interval; repeat for all subsequent breakpoints. Again, you may want to experiment with different intervals. This allows for a conveniently paced breakpoint set.
And, finally, you will probably notice that different kinds of signal sources have different "best" breakpoint parameters, so there is no one "One-Size-Fits-All" parameter set.
If you're building an interface to display data, leaving the control of these parameters to the user might be a good idea.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744215812a4563548.html
评论列表(0条)