is there any indicator which can be used in an EA to get the values of Linear Regression.

 

Hi all,

I am looking for an indicator which can be used in an EA to get values of the Linear Regression Channel.

I can manually draw the linear regression channel by using the Menu command Insert>Channel>Linear Regression.

Do we have any indicator for it where I can give the start and the end bar and derive the values of the channel. 

 
AmitJamuda:

Hi all,

I am looking for an indicator which can be used in an EA to get values of the Linear Regression Channel.

I can manually draw the linear regression channel by using the Menu command Insert>Channel>Linear Regression.

Do we have any indicator for it where I can give the start and the end bar and derive the values of the channel. 

It's just mathematics . . .  you can use ObjectGetValueByShift()  to do the linear regression for you.
 
RaptorUK:
It's just mathematics . . .  you can use ObjectGetValueByShift()  to do the linear regression for you.


I might be wrong, but doesn't ObjectGetValueByShift only work with OBJ_TREND?
 
zzuegg:

I might be wrong, but doesn't ObjectGetValueByShift only work with OBJ_TREND?
You might be right,  I've never tried it but I assumed that a Linear Regression Channel was a similar Object to a trend line . . .  "Applied to trendlines and similar objects."
 
The linear regression channel when drawn manually has three parallel lines. I am unable get the values for it. If there is an indicator which works exactly the same then the values can be easily extracted.
 
AmitJamuda:
The linear regression channel when drawn manually has three parallel lines. I am unable get the values for it. If there is an indicator which works exactly the same then the values can be easily extracted.

Where would this Indicator draw the Linear Regression Channel ?

 

You can get the values for the channel using ObjectGet()  with OBJPROP_TIME1  and  OBJPROP_TIME2 and then do your own linear regression calculation. 

 

I dont need it to draw, if it can give me the values that would work. I think i can create linear regression lines by using objectcreate function.

I was also able to get the values of the linear regression by objectget function, however the values are only the centre line. How do the get the values for the outerline. Linear regression channel has three lines. If there is a formula by which i can derive the values, that would also help, however the values should be exactly the same which i get when i draw the line manually. 

 
AmitJamuda:

I dont need it to draw, if it can give me the values that would work. I think i can create linear regression lines by using objectcreate function.

I was also able to get the values of the linear regression by objectget function, however the values are only the centre line. How do the get the values for the outerline. Linear regression channel has three lines. If there is a formula by which i can derive the values, that would also help, however the values should be exactly the same which i get when i draw the line manually. 

There is a Search box in the top right hand corner of this page . . .  I just used it to find this :  https://www.metatrader5.com/en/terminal/help/objects/channels/regression_channel
 
RaptorUK:
There is a Search box in the top right hand corner of this page . . .  I just used it to find this :  https://www.metatrader5.com/en/terminal/help/objects/channels/regression_channel


Thanks RaptorUK!

This really helps a lot. Please can you show me by a mathematical example what this line means.

 

The distance between frame of the channel and regression line equals to the value of maximum close price deviation from the regression line."

Reason: