How do you calculate the length of a line from the coordinates?

 

How do you get the zigzag line length (wavelength in essence) in any units, knowing the coordinates of two points?

Needed to compare the wavelengths of the two as a percentage


=== edit===

Respected sergeev on page 9 gave the code, I tweaked it to suit my task:

Important note: when rewinding, compressing/stretching the values will change!

#import "user32.dll"
        int GetWindowDC(int dc);
        bool GetWindowRect(int h, int& pos[4]);
        int ReleaseDC(int h, int dc);

#import

// B1 и B2 - это номера баров
double GetLengthTrendLineInPixels(int B1, double P1, int B2, double P2)
{
    int hWnd = WindowHandle(Symbol(), Period());
    int hDC = GetWindowDC(hWnd); // получаем хендл окна
    int rect[4]; GetWindowRect(hWnd, rect); ReleaseDC(hWnd, hDC);   // берем его DC
    double wW = rect[2]-rect[0]; double wH = rect[3]-rect[1];           // получаем высоту и ширину в пикселях
    double H =(WindowPriceMax()-WindowPriceMin()); double W = WindowBarsPerChart(); // переводим на график
    double lengthW = wW / W * MathAbs(B1 - B2); // ширина в пикселях; wW / W = 1 бар в пикселях
    double lengthH = wH / H * MathAbs(P1 - P2); // высота в пикселях; wH / H = 1 пункт в пикселях
    return(MathSqrt(MathPow(lengthW, 2) + MathPow(lengthH, 2)));
}
 
AlexSTAL:

How do you get the zigzag line length (wavelength in essence) in any units, knowing the coordinates of the two points?

Needed to compare the wavelengths of the two as a percentage

not a good idea, you will add up the points and time, it's not logical)
 
Well, in purely mathematical terms: the square root of the sum of the squares (Pythagoras' theorem)
 
but just the length in points if you subtract the shorter one from the longer one won't work?
 
sanyooooook:
It's not a good idea, you'll be adding up points and times, so you can't do that (not logical) )
What if instead of time - bar numbers*TF? E.g. 1: 1.5413+48*15, 2: 1.5466+1*15.
 
Abzasc:
What if instead of time - bar numbers*TF? E.g. 1: 1.5413+48*15, 2: 1.5466+1*15.
I don't care what, if it's not a price, there is no point )
 
sanyooooook:
whatever, if not the price, there is no point)

If we are talking about a relative value, it makes sense.

The point of Pythagoras is to calculate the vector length in Fibonacci arcs.

Simply, with time momentum can be said to burn out, and if the motion is not realized in a certain time, it is exhausted.

So as an impulse measurement it may well do, the main thing is that the discreteness of time should be equal in the two impulses being compared.

So feel free to add up the square of the price difference (or better to translate it into points of traveled distance) and the square of the motion bar,

and the root will give you the desired relative value for the comparison.

 
sanyooooook:
whatever, if it's not the price, there's no point )
The point is in the journey :)
 
Abzasc:
The point is the journey :)

The road is for those who walk, and the journey of a thousand miles begins with the first step.

Man, I'm going to be a sceptical philosopher with Math Math soon :o)

 

Actually, I was referring to the length of the hypotenuse :) what do you think? ;)

 
What hypotenuse can we talk about if the "cathetuses" are not just made of different dough, but in different spaces? More precisely, they are simply incommensurable.
Reason: