Ejemplo n.º 1
0
        private static int getMiniClosePrice(int kBarCount, int currentKBarNumber, Hashtable htKBar)
        {
            int miniClosePrice  = 99999;
            int iBase           = kBarCount;
            int iKBarStartIndex = 0;

            if (currentKBarNumber < kBarCount)
            {
                iKBarStartIndex = 1;
            }
            else
            {
                iKBarStartIndex = currentKBarNumber - kBarCount + 1;
            }

            for (int index = iKBarStartIndex; index <= currentKBarNumber; index++)
            {
                if (index <= 0)
                {
                    iBase--;
                    continue;
                }
                KBar kBar = (KBar)htKBar[index];
                if (kBar.Close != 0 && kBar.Close < miniClosePrice)
                {
                    miniClosePrice = kBar.Close;
                }
            }

            return(miniClosePrice);
        }
Ejemplo n.º 2
0
        public static double RSV(int kBarCount, int currentKBarNumber, Hashtable htKBar)
        {
            double rsv  = 0;
            KBar   kBar = (KBar)htKBar[currentKBarNumber];
            int    currentClosePrice = 0;

            currentClosePrice = kBar.Close;

            int miniClosePrice = Indicator.getMiniClosePrice(kBarCount, currentKBarNumber, htKBar);
            int maxClosePrice  = Indicator.getMaxClosePrice(kBarCount, currentKBarNumber, htKBar);

            rsv = (((double)(currentClosePrice - miniClosePrice)) / ((double)maxClosePrice - miniClosePrice)) * 100;

            return(rsv);
        }
Ejemplo n.º 3
0
        public static double MACD(int kBarCount, int priceType, int currentKBarNumber, Hashtable htKBar)
        {
            int iBase = kBarCount;

            int iKBarStartIndex = 0;

            iKBarStartIndex = currentKBarNumber - kBarCount + 1;
            double dResult = 0.0;

            for (int index = iKBarStartIndex; index <= currentKBarNumber; index++)
            {
                if (index <= 0)
                {
                    iBase--;
                    continue;
                }
                KBar kBar = (KBar)htKBar[index];

                if (priceType == (int)KBar.PriceType.OPEN)
                {
                    dResult += kBar.Open;
                }
                else if (priceType == (int)KBar.PriceType.LOW)
                {
                    dResult += kBar.Low;
                }
                else if (priceType == (int)KBar.PriceType.HIGH)
                {
                    dResult += kBar.High;
                }
                else if (priceType == (int)KBar.PriceType.CLOSE)
                {
                    dResult += kBar.Close;
                }
            }

            dResult = dResult / iBase;

            return(dResult);
        }