Download MetaTrader 5

Problem with creating a line with standard class CChartObjectTrendByAngle

To add comments, please log in or register
Do you know that MQL5 can create custom graphical tools?
Amir Yacoby
1192
Amir Yacoby 2013.04.09 20:31 

I have a script that creates trend lines. that I use to 

When I create a trend line using this class, with 2 points, it shifts the second point price a little lower then point 2.

For instance, EURUSD 4H I use:

line.Create(0,line_name,0,dt1,pr1,dt2,pr2)

and the line is created at dt1,pr1,dt2,pr2 - x pips

 

When I change the class to CChartObjectTrend instead of the CChartObjectTrendByAngle, the line is created ok.

Alain Verleyen
Moderator
30702
Alain Verleyen 2013.04.09 20:50  
amir_avatar:

I have a script that creates trend lines. that I use to 

When I create a trend line using this class, with 2 points, it shifts the second point price a little lower then point 2.

For instance, EURUSD 4H I use:

line.Create(0,line_name,0,dt1,pr1,dt2,pr2)

and the line is created at dt1,pr1,dt2,pr2 - x pips

 

When I change the class to CChartObjectTrend instead of the CChartObjectTrendByAngle, the line is created ok.

See if this discussion can help you.
Amir Yacoby
1192
Amir Yacoby 2013.04.09 21:02  
angevoyageur:
See if this discussion can help you.

Thanks,

From bried reading, it seems it talks about the magnet sensitivity which is relevant when you draw objects manually.
If I draw using standard library class as mentioned above, by giving exact 2 points (date + price), what can be the problem? 

Alain Verleyen
Moderator
30702
Alain Verleyen 2013.04.09 21:07  
amir_avatar:

Thanks,

From bried reading, it seems it talks about the magnet sensitivity which is relevant when you draw objects manually.
If I draw using standard library class as mentioned above, by giving exact 2 points (date + price), what can be the problem? 

I haven't tried. Are you sure that these options apply only for objects drawn manually ?

If not, then show the code you have used, what's the value of your x in "pr2 - x pips" ?

Amir Yacoby
1192
Amir Yacoby 2013.04.09 21:40  
angevoyageur:

I haven't tried. Are you sure that these options apply only for objects drawn manually ?

If not, then show the code you have used, what's the value of your x in "pr2 - x pips" ?

Here you go, please take in consideration I use EURUSD H4, and the prices you see are the lows I have on both bars.

#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"

#include <ChartObjects\ChartObjectsLines.mqh>
 
CChartObjectTrendByAngle trendline;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   if(trendline.Create(0,"line",0,D'2013.03.04 08:00',1.29822,D'2013.03.28 08:00',1.27550))
      trendline.RayRight(false);
 
}
Amir Yacoby
1192
Amir Yacoby 2013.04.09 21:41  
amir_avatar:

Here you go, please take in consideration I use EURUSD H4, and the prices you see are the lows I have on both bars.

The drawn line has second point which is placed below that price (below 1.27550), and when I look at the properties of the created line, I see a different second point price than the one I gave (not 1.27550).
Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
  • www.mql5.com
Standard Constants, Enumerations and Structures / Indicator Constants / Drawing Styles - Documentation on MQL5
Alain Verleyen
Moderator
30702
Alain Verleyen 2013.04.09 22:07  
amir_avatar:
The drawn line has second point which is placed below that price (below 1.27550), and when I look at the properties of the created line, I see a different second point price than the one I gave (not 1.27550).
Ok, I obtain 1.27553. I am searching an explanation.
Amir Yacoby
1192
Amir Yacoby 2013.04.09 22:40  
angevoyageur:
Ok, I obtain 1.27553. I am searching an explanation.
Thanks. If I change it to CCHartObjectTrend I get the right price.
Alain Verleyen
Moderator
30702
Alain Verleyen 2013.04.09 22:58  
amir_avatar:
Thanks. If I change it to CCHartObjectTrend I get the right price.
Ah ok, I missed that. Then seems to me that it is a problem of rounded price. Angle is a double, and is not always very accurate.
Amir Yacoby
1192
Amir Yacoby 2013.04.09 23:05  
angevoyageur:
Ah ok, I missed that. Then seems to me that it is a problem of rounded price. Angle is a double, and is not always very accurate.

yes I thought so, But does it mean that I can not use the angle object, even if I create the line using 2 points, and not the angle? 

How can I use it accurately then, given 2 exact points? 

Amir Yacoby
1192
Amir Yacoby 2013.04.09 23:11  
amir_avatar:

yes I thought so, But does it mean that I can not use the angle object, even if I create the line using 2 points, and not the angle? 

How can I use it accurately then, given 2 exact points? 

I just want to create the line by 2 points and then have its angel, not create a line by its angel.
12
To add comments, please log in or register