Back

Moving LinearRegression

Is moving LinearRegression of bar's close supported as a indicator ? If not, is there any example that I could use as a starting point ?
Update Backtest








Something similar - LSMA (least squares MA) indicator:


//calculate LSMA
private decimal LSMA(RollingWindow _dataW, int _lsmaPeriod)
{
decimal _lsma;
decimal _delta = 0;

//calculate lsma
_delta = 0;
for(int i=_lsmaPeriod; i >= 1; i--)
{
_delta += (i-(_lsmaPeriod+1)/3.0m)*_dataW[_lsmaPeriod-i];
}

_lsma = _delta*6/(_lsmaPeriod*(_lsmaPeriod+1));
return _lsma;
}
2

Hi @Tadas,

I'd like to make this indicator implementation. So, I need to be sure to understand how it works.

Please, can you confirm if I correctly interpreted the code?

[tex]\delta = \sum_{t=1}^{p}{\left ( i- \frac{p+1}{3} \right ) x_{t}}\\
LSMA = \frac{6 \delta} {p\left ( p+1 \right )}\\[/tex]
where:
[tex]p[/tex] is the indicator period.
[tex]x_t[/tex] is the price at time [tex]t[/tex].

Thanks in advance.

JJ
1

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


What I've provided I think is end point moving average (EPMA) - endpoint of linear regression. You can Google "Smoothing Techniques For More Accurate Signals pdf" to get article about EPMA.

There are other LSMA versions, like Woodie's LSMA: http://forum.esignal.com/showthread.php?1692-Woodies-LSMA-(Least-Square-Moving-Average)

Correct linear regression MA:
https://rtmath.net/helpFinAnalysis/html/b3fab79c-f4b2-40fb-8709-fdba43cdb363.htm
0

Thank you very much @Tadas!

I'll check the sources. Maybe I end up coding both :)
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


@Tadas,

Please check this implementation.

Any feedback will be much appreciated.
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


The Accord.NET framework has linear regression. I've used it previously, perhaps it is what you are looking for.
0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed