It appears that a number of things have changed between 8.0 and 8.5 that have broken a number of my scripts. I'm in the process of trying to fix them and I am having issues calculating the slope of a regression line.
Previously there was a LinearRegSlope object, but this no longer exists. I'm attempt to use the LinearReg object, but I'm always getting 0 when accessing the linearReg.olrslope property.
I'm initialize the linearReg object in the Strategy's create() method as follows:
linearRegression = LinearReg(this).
in the StartCalc() method:
linearRegression.price = Bars.Close;
linearRegression.length = 15;
In the strategy's CalcBar method, I attempt to get the slope:
linearRegression.olrslope;
this however always returns 0.
thanks,
-Rob
How to calculate regression slope [SOLVED]
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: How to calculate regression slope [SOLVED]
Hi Rob,
I get good values for the slope in my strats. My code is like yours, with two exceptions:
- In Create() ---> linearRegression = new LinearReg(this);
- in CalcBar() ---> linearRegression.call();
Hope this helps. If this code is incorrect, I would really like to know about it.
Thanks,
mips4pips
I get good values for the slope in my strats. My code is like yours, with two exceptions:
- In Create() ---> linearRegression = new LinearReg(this);
- in CalcBar() ---> linearRegression.call();
Hope this helps. If this code is incorrect, I would really like to know about it.
Thanks,
mips4pips