TrendLine Value

 
Hi
In MT5, I create a trend line by following code:
 
   datetime T3Time0= D'2020.11.30 14:00:00';
   double   T3Price0 = 1.19390;
   double   T3Price1 = 1.23048;
   datetime T3Time1= D'2020.12.31 17:00:00';
   ObjectCreate(0,"Trend03",OBJ_TREND,0,T3Time0,T3Price0,T3Time1,T3Price1);
then take value of Object in a specific time by this command:
Object3Val0 = ObjectGetValueByTime(0,"Trend03",TimeCurrent(),0);

then print it in Journal. But when I hover the pointer on the chart, trendLine value is different from value printed in journal.
For example, at 2020.12.24 09:00:00 on chart, it's 1.22347 but in journal it's 1.21980.
this Difference is not constant and doesn't follow a defined rule.
.
I appreciate your help.
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Object Types - Objects Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Marezaa :
Hi
I create a trend line by following code:
  then take value of Object in a specific time by this command:

then print it in Journal. But when I hover the pointer on the chart, trendLine value is different from value printed in journal.
For example, at 2020.12.24 09:00:00 on chart, it's 1.22347 but in journal it's 1.21980.
this Difference is not constant and doesn't follow a defined rule.
.
I appreciate your help.

Use a horizontal line. The trend line is still a very difficult object for you.

 
Vladimir Karputov:

Use a horizontal line. The trend line is still a very difficult object for you.

My algorithm is based on trends. Is there another function to take TrendLine's value by, instead of 

ObjectGetValueByTime()

?

 
Marezaa :

My algorithm is based on trends. Is there another function to take TrendLine's value by, instead of 

?

What exactly do you need? If you draw an inclined line (the trend line is just an inclined line), then the price will naturally change from the initial point to the final one.

See the help:  ObjectGetValueByTime

Return Value

The price value for the specified time value of the specified object.

Documentation on MQL5: Object Functions / ObjectGetValueByTime
Documentation on MQL5: Object Functions / ObjectGetValueByTime
  • www.mql5.com
ObjectGetValueByTime - Object Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Vladimir Karputov:

What exactly do you need? If you draw an inclined line (the trend line is just an inclined line), then the price will naturally change from the initial point to the final one.

See the help:  ObjectGetValueByTime

Return Value

The price value for the specified time value of the specified object.


I use the trend (or, inclined line) as a support/resistance price. I first select two Maximum points on chart then draw a line between them and continue that line to about one week later.
As I use this inclined Line as resistance(or support), want to get it's current value. But what I see in chart and in journal is different. 
I've shown this in attached JPG.

Files:
1.jpg  95 kb
 
Marezaa :

I use the trend (or, inclined line) as a support/resistance price. I first select two Maximum points on chart then draw a line between them and continue that line to about one week later.
As I use this inclined Line as resistance(or support), want to get it's current value. But what I see in chart and in journal is different. 
I've shown this in attached JPG.

You don't need to use a trand line - you don't understand how to work with it. The ObjectGetValueByTime function returns the PRICE at a point in time

 datetime   time,         // Time

Now look at what you are doing: you get the price at the time of TimeCurrent (), and place the mouse cursor somewhere in the middle of the chart.

TimeCurrent () ! = In the middle of the chart.

Documentation on MQL5: Object Functions / ObjectGetValueByTime
Documentation on MQL5: Object Functions / ObjectGetValueByTime
  • www.mql5.com
ObjectGetValueByTime - Object Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5