Need Help calculating angle between two lines on MT4 - page 2

 
Stanislav Korotky:

Yes, visual representation may differ, but algorithmically X and Y are measured in the same units - pixels, and their "squareness" is out of consideration.

Pushed by your comments I checked MT4 behaviour and while there are some minor bugs, it's doable to work with angles.

Thanks

 
Stanislav Korotky:

Not at all - this _IS_ the angle in your anisotropic space defined by currently selected units.

Sorry for late response our time zone must be way different.

Are you saying 0.35 is actually the correct angle?
 
Alain Verleyen:

Not sure what is "real life instances" ?

Working with slopes is a lot more simple and universal. Do you really needs angle ?

What I mean is the following : let's take a chart, draw the trenlines like you did and measure the visible angle. You do it on your side, I do it on mine. Supposing we draw the exact same trendlines (prices/times match), the most probable is we will never get the same angle. We have different screen resolution, different zoom, different scale, etc... For this angle to be meaningful we would have to find and agree on all these settings. A computer screen and an electronic chart window is not a paper chart.

If you still want to work with angle, you have to use the same unit for X and Y axis...what is an angle calculated from a slope using time (seconds, minutes, hours...) and price ? You need to use centimeters (probably not a good idea), or maybe pixel...or whatever unit which will make sense for both X and Y axis.

All of this being said, you can work with angle if it fits you needs and preferences, but you have to understand and deal very well with the above points to not mislead yourself.

By "real life instances" am referring to objects you can see and touch. Example calculating the angle of elevation for an inclined plane in a loading dock.

The trendlines on the chart were not drawn manually, so I want to believe pixels shouldn't come into play, since the strategy is going to run fully automated. It wouldn't really matter how they look on one chart or the other.
 

You can calculate the angle, but for this you need a fixed scale.
Otherwise, on each chart you will have different angles.

To understand this, try to find "Angle High Low". (Not advertising) :)

 
Stanislav Korotky #:

Yes, visual representation may differ, but algorithmically X and Y are measured in the same units - pixels, and their "squareness" is out of consideration.

double read_angle(double price1,long time1,double price2,long time2)
  {
   double result=0;

   int x1=0,x2=0;
   int y1=0,y2=0;
   long chart = ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0);

   ChartTimePriceToXY(0,0,time1,price1,x1,y1);
   ChartTimePriceToXY(0,0,time2,price2,x2,y2);
   int size = (int)chart;
   y1=size-y1;
   y2=size-y2;
   double angle =NormalizeDouble((MathArctan(((double)y2-(double)y1)/((double)x2-(double)x1))*180)/M_PI,1);
   result=angle;
   return(result);
  }
 
rahman jangjoo #:

When you change the vertical scale or bar width, you get a different answer. Meaningless.

Reason: