- It is zero because you never gave the object a angle value.
//--- change trend line's slope angle; when changing the angle, coordinates of the second //--- point of the line are redefined automatically according to the angle's new value ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);
OBJ_TRENDBYANGLE - Object Types - Objects Constants - Standard Constants, Enumerations and Structures - MQL4 Reference - It has a "fixed point on the chart." You moved it there.
- It is zero because you never gave the object a angle value.
- It has a "fixed point on the chart." You moved it there.
Hi,
thanks for your time.
Yes, sure, because that I need is angle of the object :)
Is that still impossible although the chart can display angle value when mouse over the object?
Thank you
when I create the OBJ_TRENDBYANGLE object based on a predefined trendline through code in EA or Indicator.
It's zero because it's not updated (available) immediately after the object is created. So you could use a timer, eventually chart event, or a loop.
string objnameline="test"; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- create timer EventSetMillisecondTimer(1); OnTick();// market close currently, I force a tick event //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- ObjectCreate(0,objnameline+"-Angle",OBJ_TRENDBYANGLE,0,Time[10],Close[10],Time[50],Close[50]); } //+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { //--- double angle_value=ObjectGetDouble(0,objnameline+"-Angle",OBJPROP_ANGLE); if(angle_value!=0) { Comment(StringFormat("%s: angle=%.1f",__FUNCTION__,angle_value)); EventKillTimer(); } } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- double angle_value=ObjectGetDouble(0,objnameline+"-Angle",OBJPROP_ANGLE); if(angle_value!=0) { Comment(StringFormat("%s: angle=%.1f",__FUNCTION__,angle_value)); } } //+------------------------------------------------------------------+
It's zero because it's not updated (available) immediately after the object is created. So you could use a timer, eventually chart event, or a loop.
Oh thank you sir Alain,
I got your excellent point,
and I really appreciate that.
I am happy, it solved.
because this thing is my dream since last years :)
Thanks, and God bless you,
Yohana
Oh thank you sir Alain,
I got your excellent point,
and I really appreciate that.
I am happy, it solved.
because this thing is my dream since last years :)
Thanks, and God bless you,
Yohana
Yohana, I got interested about that angle, I want to ask you, what are the use of that angle object? How can I make use of it during market analysis?
Yohana, I got interested about that angle, I want to ask you, what are the use of that angle object? How can I make use of it during market analysis?
Hi Chris,
Next week, I will continue my research on this subject.
Still need more effort and time to get it done.
Hope it not too far from now :)
Regards.
Hi Chris,
Next week, I will continue my research on this subject.
Still need more effort and time to get it done.
Hope it not too far from now :)
Regards.
Alright
-
There is no angle from 2 anchor points. An angle requires
distance divided by distance; a unitless number. A chart has price/time. What is
the angle of going 30 miles in 45 minutes? Meaningless!
-
You can get the slope from a trendline. Delta price / delta time. Changing the
axes scales changes the apparent angle, the slope is constant. Angle is
meaningless.
-
You can create a 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 and MetaTrader 4 - MQL4 programming forum - Page 2
-
There is no angle from 2 anchor points. An angle requires
distance divided by distance; a unitless number. A chart has price/time. What is
the angle of going 30 miles in 45 minutes? Meaningless!
-
You can get the slope from a trendline. Delta price / delta time. Changing the
axes scales changes the apparent angle, the slope is constant. Angle is
meaningless.
-
You can create a 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 and MetaTrader 4 - MQL4 programming forum - Page 2
Um! I have always thought what was the use of than angle object find int the MT platform?
I always ask where do people use such tool within the MT platform?
If its useless why did Meta Quote has include among analytical tools?
- 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 and MetaTrader 4 - MQL4 programming forum - Page 2
Thank you,
that's useful for me
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear experts,
@Alain Verleyen
@whroeder1
To this day, I am still wondering why the angle value remains zero
when I create the OBJ_TRENDBYANGLE object based on a predefined trendline through code in EA or Indicator.
Example:
Please advise me why angle value is still always 0,
is this a limitation on MQ4 and will not be improved,
or is there a solution to get angle value on OBJ_TRENDBYANGLE by code?
I know how OBJ_TRENDBYANGLE has no fixed point in chart,
but I really want to know how to get the angle value after the object have been created by code.
My last update MetaEditor MT4 is version 5.00 build 1601 (May 19, 2017)
Thank you,
Yohana