Firstly:

You know that the whole concept of “angle” on chart is flawed, don’t you?

Why? Because X and Y axes are in **different** units. X is time (days, weeks, minutes, seconds), Y is dollar (or euro, yen, pound, whatever). You can’t mathematically have angle between different units without making (invalid) assumptions that say one day is the same as one dollar.

Secondly:

Even if you had same units, your code is wrong.

Tangent function **IS** the ratio y/x. So there is no point in calculating tangent (X/Y) - it is tangent from tangent.

You would need arcus tangent to get angle from ratio. (the inverse function of tangent)

Thirdly:

Use CODE TAGS as instructed in How to use this site