public override void HandleNextTick(Tick t) { double emaVal = EMA.HandleNextTick(t); LRValues.Enqueue(emaVal); double[] Y = LRValues.ToArray(); double stdErr = 0; if (Y.Count() == X.Length) { Vector x_data = new Vector(X); Vector y_data = new Vector(LRValues.ToArray()); var poly = new PolynomialRegression(x_data, y_data, 2); for (int i = 0; i < Period; i++) { double x = (i); double y = poly.Fit(x); stdErr += Math.Pow(LRValues.ToArray()[i] - y, 2); } stdErr = Math.Sqrt(stdErr); } HighData.Enqueue(EMA[0] + STDEV * stdErr); MiddleData.Enqueue(EMA[0]); LowData.Enqueue(EMA[0] - STDEV * stdErr); }
public override void HandleNextTick(Tick t) { MiddleData.Enqueue(MIDDLE.HandleNextTick(t)); var stdev = MIDDLE.ToArray().StandardDeviation(); HighData.Enqueue(MIDDLE[0] + stdev * 2); LowData.Enqueue(MIDDLE[0] - stdev * 2); }
public override void HandleNextTick(Tick t) { double emaVal = EMA.HandleNextTick(t); LRValues.Enqueue(emaVal); double[] Y = LRValues.ToArray(); LinearRegression l = new LinearRegression(); l.Model(Y); HighData.Enqueue(EMA[0] + STDEV * l.STDERR); MiddleData.Enqueue(EMA[0]); LowData.Enqueue(EMA[0] - STDEV * l.STDERR); }