[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 76
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
You can always draw a single perpendicular to a line. This will indicate the distance from the point to the line.
There are almost always two "distances" to a circle from a given point:
From point A to the circle in this case they are AB and AC. And which one to choose as the "correct" one is not obvious.
solutions may arise from more than one, if not an infinite number. Clarification of the conditions is required.
MT4 can easily give you Ask=1.456121212 instead of 1.4561, but it (it only plays a role when working with orders) cannot "understand" what it has done.
To fix it, we use the function (example for Ask):
NormalizeDouble(Ask, Digits)
So, all values that are substituted in the order functions should be normalized before sending them to the server.
Not all values, but price values - pending order setting price, market position opening price, StopLoss and TakeProfit.
Otherwise we may understand it too straightforwardly and normalize it ... Comment for example :)
Minimising which sum - the sum of distances or the sum of squares? I still haven't heard back from the author.
You can always draw a single perpendicular to a line. This will indicate the distance from the point to the line.
There are almost always two "distances" to a circle from a given point:
From point A to the circle in this case they are AB and AC. And which one to choose as the "correct" one is not obvious.
Of course AB.
Elena, if the sum of distances, it will not work without numerical methods. There is no analytical solution in most cases (not counting the almost impossible case when a circle of a given radius can be exactly drawn through three points).
Of course, AB, who can argue - with the drawing drawn.
Imagine what will happen when trying to solve the problem by small circular motions among these three points. This very "of course AB" will keep jumping from one "branch" to another. OK, let's see how Alexey handles it.
So, the condition in digestible form:
Given N pairwise divergent points in the plane. The problem is to find for any three points of the set a circle whose sum of squares of distances from the given three points would be minimal. Then choose among all C(N,3) circles the one(s) for which the sum of squares of distances to "friendly" points is smaller than the others.
Solution.
Minimal of the distances from a given point to a circle can be calculated quite simply. If in Alexis' drawing the coordinates of point A are (xA,yA) and the coordinates of the circle centre are (x0,y0) then
d = |r - sqrt((xA-x0)^2 + (yA-y0)^2)|,
where r is the radius of the circle, and this expression is correct both for points A lying outside and inside the circle. For three points we have three such equations, each having three unknown parameters (xA, yA, r). Differentiating the sum of three d by each of them, we obtain three equations, solving which we find the required parameters.
The last step is to calculate the corresponding sum for each triplet and choose the minimum one.
By the way, due to nonlinearity of equations I advise to solve the problem numerically, there is nothing to do with analytics.
The complexity of the problem increases rapidly as N increases, because it requires calculating and enumerating N*(N-1)*(N-2)/6 circles (56 in the case of N=8)