I have following code that generates RollingWindow error and can't what parameters needed for RW periods. Maybe some better solution?
//init
RollingWindow
RollingWindow
RollingWindow
RollingWindow
//OnData
L0 = (1.0m - _gamma)*_price + _gamma*_L0[1];
_L0.Add(L0);
if(!_L0.IsReady) return;
L1 = -_gamma*L0 + _L0[1] + _gamma*_L1[1];
_L1.Add(L1);
if(!_L1.IsReady) return;
L2 = -_gamma*L1 + _L1[1] + _gamma*_L2[1];
_L2.Add(L2);
if (!_L2.IsReady) return;
L3 = -_gamma*L2 + _L2[1] + _gamma*_L3[1];
_L3.Add(L3);
if (!_L3.IsReady) return;
Michael Handschuh
Tadas Talaikis
Runtime Error: Must be between 0 and Count 1 Parameter name: i 1 (Open Stacktrace)
Michael Handschuh
if (_L0.Count < 2) return;
The idea here is that we want to index to '1' which requires a minimum Count of 2, so if less than 2, return.Tadas Talaikis
_L0.Add(L0); if(!_L0.IsReady) return; L0 = (1.0m - _gamma)*_price + _gamma*_L0[1];
Nicholas Stein
if (_L0.Samples == 0) _L0.Add(L0);
JayJayD
Tadas Talaikis
JayJayD
Mitch Christow
Jay Jay,
First off, thanks for sharing your Laguerre indicator. I took a look at it and I was wondering if you can tell me where you define the lookback period. Many of the Laguerre indicators that I have seen use a 900 period lookback (or some other value). But I did not see a place in your code where this is defined. Could you point me to the right place?
Cheers,
Mitch
JayJayD
Hey Mitch Christow,
You’re welcome!
I completely forgot this (ugly) implementation and I also forgot the math behind.
From a first sight of the formulas, there is no period, just the factor variable. And for the first actualL formula the factor range is [0, 1]. Seems the factor fulfills the same role as the alpha parameter in an exponential moving average. If so, the higher the factor, the smoother the indicator.
But I’m not sure how to transformation the factor into period.
Respect to the lookback you mention, are you sure they mean the indicator parameter?
Best
JJD
Mitch Christow
Hi JJD,
Thanks for the quick reply. I think I found part of my confusion. There are several types of Laguerre indicators out there. The one that I have seen before (and am trying to recreate) is the Laguerre ACS indicator. Here is a link to some conversations about the Laguerre ACS.
Along with a code example for a different platform of what the Laguerre ACS looks like.
I am trying to implement this custom indicator, but since I have very limited experience on quantconnect I am floundering quite a bit at the moment. If at all possible I would love to see if you can help me out with getting this one running on this platform. I'll be happy to connect privately with you if that is more efficient. Of course I would understand if you are too busy. Thanks in advance.
//---- input parameters extern double gamma=0.6; extern int MaxBars=1000; extern int MA = 2; double L0 = 0, L1 = 0, L2 = 0, L3 = 0, L0A = 0, L1A = 0, L2A = 0, L3A = 0, LRSI = 0, CU = 0, CD = 0; double Buffer1[], dummy[]; int start() { Â Â int i, j, counted_bars=IndicatorCounted(); double sum1=0; Â Â if (counted_bars < 0) return(-1); Â if (counted_bars > 0) counted_bars--; Â Â if (MaxBars>Bars) MaxBars=Bars; Â Â SetIndexDrawBegin(0,Bars-MaxBars); Â Â for(i=MaxBars-1;i>=0;i--) { sum1=0; Â Â Â L0A = L0; L1A = L1; L2A = L2; L3A = L3; Â Â Â L0 = (1 - gamma)*Close[i] + gamma*L0A; Â Â Â L1 = - gamma *L0 + L0A + gamma *L1A; Â Â Â L2 = - gamma *L1 + L1A + gamma *L2A; Â Â Â L3 = - gamma *L2 + L2A + gamma *L3A; Â Â Â CU = 0; CD = 0; Â Â Â if (L0 >= L1) CU = L0 - L1; else CD = L1 - L0; Â Â Â if (L1 >= L2) CU = CU + L1 - L2; else CD = CD + L2 - L1; Â Â Â if (L2 >= L3) CU = CU + L2 - L3; else CD = CD + L3 - L2; Â Â Â if (CU + CD != 0) LRSI = CU / (CU + CD); Â Â Â dummy[i] = LRSI; Â Â Â if (MA < 2) Buffer1[i] = dummy[i]; else { for (j=i; j < i+MA; j++) sum1 += dummy[j]; Buffer1[i] = sum1/MA; } Â Â }
Cheers,
Mitch
Mitch Christow
Quick addendum. What is throwing me the most about this algorithm is how to apply a X period moving average to the resulting calculation (line 27) to smooth out the results. I am not sure how to apply that to a custom indicator on the LEAN engine.
JayJayD
Hey Mitch,
For sure you can do it by yourself, is easier that what you think!
Some tips:
Once you have something on hands, I’ll be very glad to help.
Feel free to contact me at QuantConnect’s slack at anytime.
Good luck!
Mitch Christow
HI JJD,
Thanks for all the tips. I will give it a shot and see how far I can get. It is much apprecaited.
Cheers,
Mitch
Tadas Talaikis
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!