Download MetaTrader 5

Get Values of Channel's Second Line

To add comments, please log in or register
Andriy Moraru
1259
Andriy Moraru  

I can use ObjectGetValueByShift() to get the values of the channel's main line. But how do I get values of the second line? Is it possible at all?

Calculating using linear equation formula based on time yields incorrect results due to non-linear time change in the chart.

Simon Gniadkowski
Moderator
18027
Simon Gniadkowski  
enivid:

I can use ObjectGetValueByShift() to get the values of the channel's main line. But how do I get values of the second line? Is it possible at all?

Calculating using linear equation formula based on time yields incorrect results due to non-linear time change in the chart.

Look up how the channel is drawn in the TA section of this site, from that you should be able to work it out.
Andriy Moraru
1259
Andriy Moraru  
Sorry, but that fails to provide any useful information on my inquiry.
Simon Gniadkowski
Moderator
18027
Simon Gniadkowski  
enivid:
Sorry, but that fails to provide any useful information on my inquiry.

Really ?  what did you expect ?  code ?

 

https://www.metatrader5.com/en/terminal/help/objects/channels/regression_channel

 

"Linear Regression Channel consists of two parallel lines, equidistant up and down from the line of linear regression trend. The distance between frame of the channel and regression line equals to the value of maximum close price deviation from the regression line.

Andriy Moraru
1259
Andriy Moraru  
Sorry, but I was asking about OBJ_CHANNEL, not about OBJ_REGRESSION.
Simon Gniadkowski
Moderator
18027
Simon Gniadkowski  
enivid:
Sorry, but I was asking about OBJ_CHANNEL, not about OBJ_REGRESSION.

So you mean an Equidistant Channel ?  

OBJ_CHANNEL5Channel. Uses 3 coordinates.

 

It has 3 coordinates . . .   draw one on your chart manually,  see what the 3rd coordinate is used for. 

Andriy Moraru
1259
Andriy Moraru  

Thanks but I know what the 3rd coordinate is used for. It helps little in finding out the value (price) of the second line at some given shift.

It could be calculated for cases when the 3rd coordinate is located at current bar or earlier. But it seems impossible for cases when the third coordinate is placed somewhere in the future part of the chart.

Simon Gniadkowski
Moderator
18027
Simon Gniadkowski  
enivid:

Thanks but I know what the 3rd coordinate is used for. It helps little in finding out the value (price) of the second line at some given shift.

It could be calculated for cases when the 3rd coordinate is located at current bar or earlier. But it seems impossible for cases when the third coordinate is placed somewhere in the future part of the chart.

The lines are parallel,  so the price difference between the lines is constant.  Get the price difference between the 3rd coordinate and the other coordinate that is at the same time and you have the price offset between the lines . . . .   isn't that what you need ?  add this offset to the value of the ObjectGetValueByShif() and you have the value of the 2nd line at a specific bar number.  Job done.

All you needed to do was draw a channel manually on a chart and investigate it's "properties",  where the coordinates are, how they relate to each other.  It's pretty simple. 

Andriy Moraru
1259
Andriy Moraru  
I wish it would be that simple. We can get the price offset between two lines only if the time of the 3rd coordinate is the same as the time of 1st or 2nd coordinates. We could even calculate the offset if the 3rd coordinate has bar shift >= 0, but I cannot find a way to get it when this shift is negative coordinate is placed in future and doesn't match time of 1st/2nd coordinate.
Simon Gniadkowski
Moderator
18027
Simon Gniadkowski  
enivid:
I wish it would be that simple. We can get the price offset between two lines only if the time of the 3rd coordinate is the same as the time of 1st or 2nd coordinates. We could even calculate the offset if the 3rd coordinate has bar shift >= 0, but I cannot find a way to get it when this shift is negative coordinate is placed in future and doesn't match time of 1st/2nd coordinate.
OK,  I see . . .  why can't you extrapolate the price for the 1st/2nd coordinate to a time the same as the 3rd coordinate to get the offset ? 
Andriy Moraru
1259
Andriy Moraru  
We cannot use time as x in f(x) = kx + b calculation because charts are non-linear in respect to time. For example, daily charts have weekends and holidays omitted, so the neighboring bars could be 1 day apart or 3 days apart.
12
To add comments, please log in or register