コード例 #1
0
        public static CandleStatus[] UnPacks(BigInteger package, int PackageCount)
        {
            int packageKey = 2047;

            CandleStatus[] output     = new CandleStatus[PackageCount];
            BigInteger[]   singleData = new BigInteger[PackageCount];

            byte getSingleDatashift = 0;

            for (int i = 0; i < PackageCount; i++)
            {
                singleData[i]       = (package & (packageKey << getSingleDatashift)) >> getSingleDatashift;
                getSingleDatashift += 11;
            }

            byte Key1 = 1;
            byte Key2 = 3;

            for (int i = 0; i < PackageCount; i++)
            {
                output[i].Volume      = (short)(singleData[i] & Key1);
                output[i].LowerShadow = (short)((singleData[i] & Key2 << 1) >> 1);
                output[i].Body        = (short)((singleData[i] & Key2 << 3) >> 3);
                output[i].UpperShadow = (short)((singleData[i] & Key2 << 5) >> 5);
                output[i].GAP         = (short)((singleData[i] & Key1 << 7) >> 7);
                output[i].Direction   = (short)((singleData[i] & Key1 << 8) >> 8);
                output[i].LowerLow    = (short)((singleData[i] & Key1 << 9) >> 9);
                output[i].HigherHigh  = (short)((singleData[i] & Key1 << 10) >> 10);
            }
            return(output);
        }
コード例 #2
0
        private BigInteger Mask(CandleStatus data)
        {
            BigInteger temp = 0;

            temp = temp | data.Volume;
            temp = temp | (data.LowerShadow << 1);
            temp = temp | (data.Body << 3);
            temp = temp | (data.UpperShadow << 5);
            temp = temp | (data.GAP << 7);
            temp = temp | (data.Direction << 8);
            temp = temp | (data.LowerLow << 9);
            temp = temp | (data.HigherHigh << 10);
            return(temp);
        }
コード例 #3
0
        public static CandleStatus UnPack(BigInteger package)
        {
            CandleStatus output = new CandleStatus();
            byte         Key1   = 1;
            byte         Key2   = 3;

            output.Volume      = (short)(package & Key1);
            output.LowerShadow = (short)((package & Key2 << 1) >> 1);
            output.Body        = (short)((package & Key2 << 3) >> 3);
            output.UpperShadow = (short)((package & Key2 << 5) >> 5);
            output.GAP         = (short)((package & Key1 << 7) >> 7);
            output.Direction   = (short)((package & Key1 << 8) >> 8);
            output.LowerLow    = (short)((package & Key1 << 9) >> 9);
            output.HigherHigh  = (short)((package & Key1 << 10) >> 10);

            return(output);
        }
コード例 #4
0
        public BigInteger[] getMaskData(CandleStickData[] rawData, int DayOfAvgVolume)
        {
            int Rawsize = rawData.Length;

            CandleStatus[] maskData = new CandleStatus[Rawsize];
            BigInteger[]   output   = new BigInteger[Rawsize];

            double[] body      = new double[Rawsize];
            double[] UpShadow  = new double[Rawsize];
            double[] LowShadow = new double[Rawsize];

            double avgBody      = 0;
            double avgUpShadow  = 0;
            double avgLowShadow = 0;
            double SD_Body      = 0;
            double SD_UpShadow  = 0;
            double SD_LowShadow = 0;

            double[] Uscentroid   = { -0.552689665062178, 0.615773990557240, 2.955830732137820 };
            double[] LScentroid   = { -0.479483091630587, 0.571950622887706, 3.379221758271600 };
            double[] Bodycentroid = { -0.568489143858862, 0.492655804140342, 2.732240511936160 };

            //Calculate Average
            for (int i = 0; i < Rawsize; i++)
            {
                body[i] = Math.Abs(rawData[i].Open - rawData[i].Close);
                if (rawData[i].Open >= rawData[i].Close)
                {
                    UpShadow[i]  = rawData[i].High - rawData[i].Open;
                    LowShadow[i] = rawData[i].Close - rawData[i].Low;
                }
                else
                {
                    UpShadow[i]  = rawData[i].High - rawData[i].Close;
                    LowShadow[i] = rawData[i].Open - rawData[i].Low;
                }

                avgBody      += body[i];
                avgUpShadow  += UpShadow[i];
                avgLowShadow += LowShadow[i];
            }
            avgBody      /= Rawsize;
            avgUpShadow  /= Rawsize;
            avgLowShadow /= Rawsize;
            //Set SD
            SD_Body      = GetSD(body);
            SD_LowShadow = GetSD(LowShadow);
            SD_UpShadow  = GetSD(UpShadow);

            //Set property
            for (int i = 0; i < maskData.Length; i++)
            {
                maskData[i].Direction   = checkDirection(rawData[i].Open, rawData[i].Close);
                maskData[i].Body        = statusBody(body[i], SD_Body, avgBody, Bodycentroid);
                maskData[i].LowerShadow = statusLowerShadow(LowShadow[i], SD_LowShadow, avgLowShadow, LScentroid);
                maskData[i].UpperShadow = statusUpperShadow(UpShadow[i], SD_UpShadow, avgUpShadow, Uscentroid);

                if (i != 0)
                {
                    maskData[i].HigherHigh = checkHH(rawData[i], rawData[i - 1]);
                    maskData[i].LowerLow   = checkLL(rawData[i], rawData[i - 1]);
                    maskData[i].GAP        = checkGAP(rawData[i], rawData[i - 1]);
                }
                if (i - DayOfAvgVolume >= 0)
                {
                    double avgLast = 0;
                    int    LastDay = 1;
                    for (int j = i; j < (i + DayOfAvgVolume); j++, LastDay++)
                    {
                        avgLast += rawData[j - LastDay].Volume;
                    }
                    avgLast           /= DayOfAvgVolume;
                    maskData[i].Volume = checkVolume(rawData[i].Volume, avgLast);
                }
                else
                {
                    maskData[i].Volume = 0;
                }
            }

            for (int i = 0; i < maskData.Length; i++)
            {
                output[i] = Mask(maskData[i]);
            }
            return(output);
        }