Can't get OBJPROP_ANGLE to return value

 
Hello all,

Am I doing this correct? I drew a Trendline (test) and I want to return the Angle...

ObjectCreate("test", OBJ_TREND, 0, Time[10], High[10], Time[0], High[0]);
ObjectSet("test", OBJPROP_STYLE, STYLE_SOLID);
ObjectSet("test", OBJPROP_COLOR, Red);        
ObjectSet("test", OBJPROP_WIDTH, 1);
ObjectSet("test", OBJPROP_RAY, 1);
double angle=ObjectGet("test", OBJPROP_ANGLE);
Alert(DoubleToStr(angle,0));



Draws the Trendline, but just returns 0 for the angle.

Any thoughts?
-charlie


 
Any help would be appreciated.
-charliev
 
ObjectSet("test", OBJPROP_RAY, 1);
ObjectsRedraw();
double angle=ObjectGet("test", OBJPROP_ANGLE);
 
ObjectSet("test", OBJPROP_RAY, 1);
ObjectsRedraw();
double angle=ObjectGet("test", OBJPROP_ANGLE);




Slawa,

I added ObjectsRedraw() to my example, and it still only returns 0.
I'm on build 195.
Any thoughts?

-charliev
 
ObjectSet("test", OBJPROP_RAY, 1);
ObjectsRedraw();
double angle=ObjectGet("test", OBJPROP_ANGLE);




Slawa,

I added ObjectsRedraw() to my example, and it still only returns 0.
I'm on build 195.
Any thoughts?

-charliev



Try
DoubleToStr(angle,8)
to see if it is somewhere less then 1
 

Try
DoubleToStr(angle,8)
to see if it is somewhere less then 1


Slawa,

The result after trying DoubleToStr(angle,8) is:
"0.00000000"

This angle is a good 30 degrees... Still 0.

Is this working for you?

-charliev
 
See sample script "MQL4: Rotating text"

BTW I don't see in your sample angle set. By default its value is 0
 
See sample script "MQL4: Rotating text"

BTW I don't see in your sample angle set. By default its value is 0


I'm not setting the angle... just creating 2 points to draw the trendline, THEN I'd like to know what angle it its. If I can't read the angle of the newly created line (except by setting it), can you provide a code example on how to get the angle of the trendline in degrees?

Thanks,
-charliev
 
Sorry for my mistake. There is limited version.

See rotate_text.mq4 in your experts\scripts directory
 
I'm not setting the angle... just creating 2 points to draw the trendline, THEN I'd like to know what angle it its. If I can't read the angle of the newly created line (except by setting it), can you provide a code example on how to get the angle of the trendline in degrees?

Thanks,
-charliev


The principle is :

angle in radians = MathArcTan((P2-P1) / (T2-T1));
angle in degree = 180 * angle in radians / MathArccos(-1.0);

but there is a prolbem with the unities, according to the timeframe, the zoom, and so. So, I think it should be better if you can work with the tangeante of the angle; the real angle in degree is not meaningfull.
Hope this help.
 
Slawa and MichelB thank you for your input.

Slawa, maybe this could be put on the "wish list"... drawing a trendline, and having the angle returned. Just a thought.

-charliev
Reason: