ObjectCreate(0,"a",OBJ_TRENDBYANGLE,0,iTime(_Symbol,PERIOD_H1,10),iClose(_Symbol,PERIOD_H1,10),iTime(_Symbol,PERIOD_H1,15),iClose(_Symbol,PERIOD_H1,15))
-
TL by angle only has one anchor point. Then you must set the OBJPROP_ANGLE.
-
There is no angle from 2 anchor points. An angle requires distance divided by distance; a unit-less number. A chart has price and time. What is the angle of going 30 miles in 45 minutes? Meaningless!
-
You can get the slope from a trendline: m=ΔPrice÷ΔTime. Changing the price scale, bar width, or window size, changes the apparent angle, the slope is constant. Angle is meaningless.
-
You can create an angled line using one point and setting the angle (Object Properties - Objects Constants - Standard Constants, Enumerations and Structures - MQL4 Reference.) The line is drawn that angle in pixels. Changing the axes scales does NOT change the angle (and thus is meaningless.)
-
If you insist, take the two price/time coordinates, convert them to pixel coordinates and then to apparent angle with arctan.
How to get the angle of a trendline and place a text object to it? - Trend Indicators - MQL4 programming forum - Page 2
-
for create TL we need two point :
iTime(_Symbol,PERIOD_H1,10),iClose(_Symbol,PERIOD_H1,10),iTime(_Symbol,PERIOD_H1,15),iClose(_Symbol,PERIOD_H1,15)
when i can create this TL and going to properties and see angle in degrees value , system automatic calculate this angle , so we must can read this value without any extra code .
When the system itself calculates it, why should I calculate it again? I just want to read the value of that variable
Use ChartRedraw() function after setting up your object properties, then you're able to print/get values correctly.
i also using ChartRedraw() . when i using debugging mode , my code works fine ! but when i use backtest or real time my code work wrong !
please click on GIF and look my code.
حاجی دهنم سرویس شد هرچی باهاش ور رفتم درست کار نکرد . ببین میتونی یه کمکی کنی
i also using ChartRedraw() . when i using debugging mode , my code works fine ! but when i use backtest or real time my code work wrong !
please click on GIF and look my code.
حاجی دهنم سرویس شد هرچی باهاش ور رفتم درست کار نکرد . ببین میتونی یه کمکی کنی
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
i create Trend line by angle with code
and draw trend line and selectable , when i select trend line and go to properties i see angle in degrees , but when i want read angle with code:
after run this line of code trend line changed and print "90".
i see second trend line angle is '90' degree , but why trend line changed ? any advise ?