Value 2P using OBJ_TRENDBYANGLE

 

Hi, I created an indicator that generates a line using OBJ_TRENDBYANGLE in MT4.

   angle_line1="angle_line1";
   angle=12;
   price1=25.10;
   price2=0;

   ObjectCreate(angle_line1,OBJ_TRENDBYANGLE,0,Time[1],price1,Time[0],price2);
   ObjectSet(angle_line1, OBJPROP_RAY, false); 
   ObjectSet(angle_line1,OBJPROP_ANGLE,angle);
   ObjectSet(angle_line1,OBJPROP_COLOR,clrRed);

   the red segment is drawn with an inclination of 12 degrees. Perfect!

   Now I want to extract the price of point 2

   double data2=ObjectGet(angle_line1,OBJPROP_PRICE2);
   Print(data2);

   I see 0.0

   Why ? Is it a bug?

Thanks to those who answer me

 
In future please post in the correct section
I have moved your topic to the MQL4 and Metatrader 4 section.
 
AlfredCat:    Now I want to extract the price of point 2    I see 0.0   Why ? Is it a bug?
  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  3. Yes, in your code. By Angle only has one point and the angle; there is no second one to get. Try ObjectGetValueByTime or ObjectGetValueByShift
  4. but why bother?
    1. 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!

    2. You can get the slope from a trendline: m=ΔPrice÷ΔTime. Changing the axes scales changes the apparent angle, the slope is constant. Angle is meaningless.

    3. 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.)

    4. 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
Reason: