Пример #1
0
        public static object EMA(object[] Data, double DecayFactor, object FullSeriesOpt, object ReverseDataOpt)
        {
            bool fullSeries  = Utils.GetOptionalParameter(FullSeriesOpt, false);
            bool reverseData = Utils.GetOptionalParameter(ReverseDataOpt, false);

            double[] data = Utils.GetVector <double>(Data);

            if (reverseData)
            {
                data = data.Reverse().ToArray();
            }

            EMA em = new CommonTypes.EMA(DecayFactor);

            double[,] ret = new double[data.Length, 1];
            for (int i = 0; i < ret.Length; ++i)
            {
                int index = (reverseData ? ret.Length - i - 1 : i);
                ret[index, 0] = em.Update(data[i]);
            }

            if (fullSeries)
            {
                return(ret);
            }
            else
            {
                return(reverseData ? ret[0, 0] : ret[data.Length - 1, 0]);
            }
        }
Пример #2
0
        public MACD(double fastSmoothingFactor, double slowSmoothingFactor, double signalSmoothingFactor)
        {
            FastSmoothingFactor = fastSmoothingFactor;
            Fast = new EMA(FastSmoothingFactor);

            SlowSmoothingFactor = slowSmoothingFactor;
            Slow = new EMA(SlowSmoothingFactor);

            SignalSmoothingFactor = signalSmoothingFactor;
            Signal = new EMA(SignalSmoothingFactor);

            Signal.Update(0);

            MACDCrossedSignal   = false;
            MACDCrossedZero     = false;
            MACDStockDivergence = false;

            maxValue     = 0;
            maxMACDValue = 0;
        }