Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }