0
$\begingroup$

enter image description here

In the above image I know the value of the adjacent side. It's $298$. I know the value of the opposite side it's $806.8$. The problem is $298$ is in units of 'bars' on a stock chart and the value of $806.8$ is representing the price difference. We can't mix different units and get a meaningful answer with the standard Pythagorean theorem. My goal is to calculate what the angle $\theta$ is in the image above.

For example on the site tradingview.com, I drew this image.

enter image description here

Notice it says the angle is $-15$ degrees. It's able to calculate that because it can assume it's a right triangle (you can kind of see it with the dashed lines acting as the other side of the right triangle). The $-806.8$ is representing degree's of difference downwards; So that would be the opposite side in my diagram. The $298$ bars would be the adjacent side.

This is exactly what I'm trying to do. I uploaded the image I used above and just inversed it to further clarify. The words are just messed up. This matches the same orientation as the tradingview line image.

enter image description here

What would be the best way to go about solving this problem?

Acceptable Answers:

I am writing a computer program to help solve this, therefore any solution that requires multiple 'testing' is OK. I can just run a loop to try different values until we get something that works.

Converting the price and time into some combined unit is OK, all we ultimately care about is the angle

I could program something where the user plugs in different values until the angle 'looks' like a $45$ degree angle to get the ratios right.

So this should give a lot of creative possibilities to discover an answer and I'm not sure the best route to go. I have looked around and found no solutions for this kind of problem.

$\endgroup$
4
  • $\begingroup$ Welcome to Mathematics Stack Exchange. I removed the pythagorean-triples tag, because the lengths are not all integers $\endgroup$ Jul 15, 2020 at 22:33
  • $\begingroup$ That's fine, I wasn't sure what to use for this. Any tag suggestions? $\endgroup$ Jul 15, 2020 at 22:35
  • $\begingroup$ Maybe I don't understand the question, but if the units on the sides are different, then the angle depends on the scales of each side. If that's not the case, and you have the length of each side, then you can just use trig. $\endgroup$
    – DMcMor
    Jul 15, 2020 at 22:38
  • $\begingroup$ Can you elaborate more on what you mean with scale of each side? $\endgroup$ Jul 15, 2020 at 23:11

1 Answer 1

1
$\begingroup$

There is no natural metric (no sense of length or angle) on a graph with different units. You can stretch the graph horizontally or vertically and change the apparent angle.

So just pick any numbers $a,b>0$ (with appropriate units) and say that the hypotenuse is

$$\sqrt{a*(\text{adjacent})^2+b*(\text{opposite})^2}$$

and the angle is

$$\arccos\frac{\sqrt a*(\text{adjacent})}{\sqrt{a*(\text{adjacent})^2+b*(\text{opposite})^2}}=\arctan\frac{\sqrt b*(\text{opposite})}{\sqrt a *(\text{adjacent})}.$$

See inner product and metric tensor.

$\endgroup$
15
  • $\begingroup$ Can you give me an example with the number I gave? I'm curious how that would look plugged into your equation. I should mention that it's not possible to have the adjacent and opposite be the same units, so not sure what you meant by appropriate units. Any help is appreciated, trying for now to go through the equations to see if it creates a similar angle result. $\endgroup$ Jul 16, 2020 at 1:48
  • $\begingroup$ You could take $$a=\frac{1}{(298\text{ bar})^2},\quad b=\frac{1}{(\$806.8)^2}$$ to make the angle exactly $45^\circ$ (I'm assuming it's between $0$ and $90^\circ$). $\endgroup$
    – mr_e_man
    Jul 16, 2020 at 1:54
  • $\begingroup$ Just treat the units as algebraic variables, and try to make them cancel out. Regardless of the numerical value, $a$ should have units of $1/(\text{bar})^2$ and $b$ should have units of $1/\$^2$. $\endgroup$
    – mr_e_man
    Jul 16, 2020 at 1:56
  • 1
    $\begingroup$ If you have a graph with a specific shape (that you can't stretch), then you probably need the conversion factors between $\text{bar},\$ $ and pixels (or whatever the graph's length units are). $\endgroup$
    – mr_e_man
    Jul 16, 2020 at 2:14
  • 1
    $\begingroup$ You have one triangle with $\theta$ and $\text{adj., opp.}$. Plug these into my commented equation to get the ratio $\sqrt b/\sqrt a$. Then put this ratio into the equation in the answer above, to find the angle $\theta'$ of any other right triangle with lengths $\text{adj.', opp.'}$: $$\theta'=\arctan\left(\frac{\sqrt b}{\sqrt a}\frac{\text{opp.'}}{\text{adj.'}}\right)$$ $\endgroup$
    – mr_e_man
    Jul 16, 2020 at 2:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .