public static List <decimal> Linreg(List <decimal> source, int period = 14) { // int outBegIdx, outNbElement; double[] outValues = new double[source.Count]; var sourceFix = source.Select(x => Convert.ToDouble(x)).ToArray(); var ema = TA.LinearReg(0, source.Count - 1, sourceFix, period, out int outBegIdx, out int outNbElement, outValues); if (ema == TA.RetCode.Success) { return(outValues.Take(outNbElement).Select(x => Convert.ToDecimal(x)).ToList()); } throw new Exception("Could not calculate RSI!"); }
public static Pine Linreg(Pine source, int period = 14) { // int outBegIdx, outNbElement; double[] outValues = new double[source.Count]; var sourceFix = source.ToArray(); var ema = TA.LinearReg(0, source.Count - 1, sourceFix, period, out int outBegIdx, out int outNbElement, outValues); if (ema == TA.RetCode.Success) { return(outValues.Take(outNbElement).ToPine()); } throw new Exception("Could not calculate RSI!"); }