Calculating an angle in chart price x time

 

I know it sounds strange, and I did some research in this forum before, but I couldn't understand how you guys calculate angles.


The regular way to calculate an angle in a chart price x time would be like this:

tan = (Close [x] - Close [y]) / (Time [x] - Time [y]);

angle = MathArctan (tan) * 3.14 / 180;

and then the result would be the angle of the chart in degrees so I could use it in my analyses. I know that visually the angle can be different because it depends on the monitor, size of the screen, etc, but in this case, it doesn't depend since I'm using exact values of time and price.


The only problem is that they have different scales so the result is wrong. What can I do to fix this? Using M15, I was thinking I could divide of multiply (Time [x] - Time [y]) for some value, but have no idea which one.


I also saw some people talking about slopes. How can I use that in this example?


Thanks guys. This is my first post. I want to develop an EA based on angles to make me a millionaire! The idea is just to detect angles so I could get big price falls and rises in a M15 chart, like the one the picture below. :-)


Marco



 

Slopes and angles are interchangeable (https://www.mql5.com/en/forum/123370). IMHO, It's better to calculate slope (the calculation is faster, easier and more accurate). What's important is being consistent with axis units.

double m = (Close [x] - Close [y]) / (Time [x] - Time [y]);    // slope in units of [price/second]

Or u can calculate this as [points/second] or [pips/minute], etc... Doesn't matter as long as u are consistent with the units.


p.s. Whether or not this calculation can be considered a good measure of anything is a different subject...

 

Thanks Gordon,


I understand what you said. So basically what I'm doing is right, but I don't get an angle, but a slope. The problem is that this way I can't compare it with an angle. I wanted to compare it with 60º to see if what I have is a big angle or not.


I guess then I should plot some lines on my chart to see which declination corresponds to the angle I wanted. Even though it will be different if I zoom in or out or even change monitor, the "angle" I get for my monitor using M15 and a determined scale will work!


For example, I got the points (1.22124, 2010/05/27 16:45; 1.23676, 2010/05/27 18:45) and can calculate m. Is there a function to draw a line from 2 points so I could tell by looking which angle is this ?


....


Got it!!!


ObjectCreate ("line", OBJ_TREND, 0, D'2010.05.27 16:45', 1.22124, D'2010.05.27 18:45', 1.23676);


I'll draw many lines to try to discover the values for comparing it with some angles and will post the results later.

 
marcoblbr:

The problem is that this way I can't compare it with an angle. I wanted to compare it with 60º to see if what I have is a big angle or not.

As I said - u can calculate slope from angle... So compare it with the slope associated with that particular angle (and just forget about angles altogether).


I guess then I should plot some lines on my chart to see which declination corresponds to the angle I wanted. Even though it will be different if I zoom in or out or even change monitor, the "angle" I get for my monitor using M15 and a determined scale will work!

No you shouldn't! The actual angle on the screen has no meaning. Angles only have a meaning when both axis have the same units (and same scaling). For example let's take your 60º angle - how do u determine which chart has the "true" 60º angle? What units and scales are on this chart? How did u come up with 60º in the first place? Why is that a "big" angle? What does "big" mean anyway?!


Think about it carefully... I see where u r going with this and I am certain u r just wasting your time. (IMHO).

 

The idea behind the EA I want to make is really simple: I want to take advantage of situations like the one on the graph I showed. When I detect fast raises of price in a really short period of time (M15), I buy and close later. The 60º is just one angle that looks good on my monitor and can help me decide whether there is a fast raise or not.


If I don't use any kind of angles, I don't know how could I write an EA for this strategy because the whole idea of "fast raises" is based on angles. I just started on Forex, and I don't have a lot of experience but I really want to try this strategy. Honestly, what do you think of this idea? Any suggestions to improve it?


Thanks!

 

Slope is an angle. It is just a consistant measure of the angle from horizontal based on the rise(how much price has risen or fallen) and run (since what time) a 1:1 slope is 45º. Slope will also tell you if the line is rising or falling. Slope will ignore any scaling or how your line looks... it is just interested in the angle from horizontal between 2 fixed points.

https://en.wikipedia.org/wiki/Slope

Hope that helps (And I hope I remeber this correctly 'cos it's a while since I did slope calcs)

V

 

It is good topic trying to understand the angle in chart.

I think the underlying topipc about slope and angle is this: Cartesian coordinate vs Polar coordinate

It seem what we know about angle does not seems existing in our forex chart because we look differnet chart per our montior resolution.

 
Young Ho Seo: It is good topic

Don't double post! You already had another thread open.

          General rules and best pratices of the Forum. - General - MQL5 programming forum
Are 'Slope' and the 'Angle on charts the same thing / quantity?
Are 'Slope' and the 'Angle on charts the same thing / quantity?
  • 2010.01.24
  • www.mql5.com
If a chart is locked at a 1 to 1 ratio, is the angle of the line between the closing of 2 adjacent bars, isn't the 'slope' the same thing as the an...
Reason: