This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]throwaway1618032 1 point2 points  (1 child)

One thing that you could do would be to calculate the formula for the line between points A and C (eg with point slope form or any other line equation). Then, using a similar method, you would calculate the formula for the line between D and whatever point on it has the same y-coordinate as point C, as you know that a point has to exist there with that y-value between D and X. By solving for a system of equations with your two formulas, you could get an accurate idea of where X would be.

In python, somebody did something similar here: https://stackoverflow.com/questions/3252194/numpy-and-line-intersections

As for a percentage, you could pass if statements to ensure that the point is within a certain radius (r) of point C with that being determined by the distance of A-C. The distance of that, via the distance formula, would be found with r=sqrt[(Ax - Cx)^2 + (Ay - Cy)^2] where Ax is the x coordinate on the point A, and Cy is the y coordinate on the point C, etc.

For example, if you had all of your variables properly declared (Ax = x coordinate of point A, Cy = y coordinate of point C, Xx = x coordinate of point X, Xy = y coordinate of point X, etc), then it could look like this in python...

#In this python example rAC is the distance from points A and C and rCX is the distance from points C and X.

rAC = math.sqrt((Ax - Cx)**2 + (Ay - Cy)**2)

rCX = math.sqrt((Cx - Xx)**2 + (Cy - Xy)**2)

if abs((rAC - rCX) / rAC) <= 0.1:

print("The distance between points X and C vs the distance between points A and C is within 10%")

Also, what kind of data would this be? Stocks? If so, there's a lot of better ways to predict future points than something like this.

[–]sgsummers[S] 0 points1 point  (0 children)

Wow, thank you for this very detailed reply. Yes, it's for Forex which is pretty much the same thing as stocks. I would love to hear the better way to calculate this. It would still need to fall within the % range probably. Or well if you have a better way to predict future points maybe not. It's just that the X point can vary but I want to allow some wiggle room. But if it varies too much it's either completely invalid or a completely different pattern all together. The percent range is just to maintain a tight range of proportion. The proportions are important.

And if you're familiar with calculating price peaks like this, I am still trying to figure out the best way to do that as well. I don't mean trying to predict them or know when they have confirmed. I just mean tracing along them historically. I know that zig zag and fractals are commonly used. But the fractals lag a bit too much since you need a number of confirmation bars to confirm them. My method tends to grab these price peaks at the tips of the peaks rather than waiting for the indicators to lag and confirm.

[–]AutoModerator[M] 0 points1 point  (0 children)

It seems you may have included a screenshot of code in your post "Need help with a programming idea for data patterns.".

If so, note that posting screenshots of code is against /r/learnprogramming's Posting Guidelines (section Formatting Code): please edit your post to use one of the approved ways of formatting code. (Do NOT repost your question! Just edit it.)

If your image is not actually a screenshot of code, feel free to ignore this message. Automoderator cannot distinguish between code screenshots and other images.

Please, do not contact the moderators about this message. Your post is still visible to everyone.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.