MT4 but should be similar. Please check if that helps.

Is there a solution to get angle value on OBJ_TRENDBYANGLE by code?
- 2018.04.08
- www.mql5.com
Dear experts, @Alain Verleyen @whroeder1 To this day, I am still wondering why the angle value remains zero when I create the OBJ_TRENDBYANGLE obje...
Alain Verleyen:
MT4 but should be similar. Please check if that helps.
MT4 but should be similar. Please check if that helps.
Excellent, Thanks
Hi!
Just plug in the coordinates of two points into this function. The angle will be the same as the TrendLinebyAngle on the chart. Absolutely no bugs!
double getAngleTwoPoints(double price1,long time1,double price2,long time2, long chart_id = 0) { double result=0; int x1=0,x2=0; int y1=0,y2=0; long chart = ChartGetInteger(chart_id,CHART_HEIGHT_IN_PIXELS,0); ChartTimePriceToXY(chart_id,0,time1,price1,x1,y1); ChartTimePriceToXY(chart_id,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); }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi Guys,
I Created a trend line by angle like it:
When I try get a angle:
double trend_angle = trend.Angle();
I get 90.0 even if I change points coordinates like it.
I read many times this documentation: https://www.mql5.com/en/docs/standardlibrary/chart_object_classes/obj_lines/cchartobjecttrendbyangle
Thanks