public static Pine Ema(Pine source, int period) { double[] emaValues = new double[source.Count]; var sourceFix = source.ToArray(); var sma = TA.Ema(0, source.Count - 1, sourceFix, period, out int outBegIdx, out int outNbElement, emaValues); if (sma == TA.RetCode.Success) { return(emaValues.Take(outNbElement).ToPine()); } throw new Exception("Could not calculate EMA!"); }
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!"); }
public static Pine Sma(Pine source, int period = 30) { // int outBegIdx, outNbElement; double[] smaValues = new double[source.Count]; //List<double?> outValues = new List<double?>(); var sourceFix = source.ToArray(); var sma = TA.Sma(0, source.Count - 1, sourceFix, period, out int outBegIdx, out int outNbElement, smaValues); if (sma == TA.RetCode.Success) { return(smaValues.Take(outNbElement).ToPine()); /*FixIndicatorOrderingD(smaValues.ToList(), outBegIdx, outNbElement);*/ } throw new Exception("Could not calculate SMA!"); }