コード例 #1
0
        void calcVolumeByPrice()
        {
            Share share = getShare();

            if (share.getCandleCount() < 5)
            {
                return;
            }

            float highest = share.getHighestPrice();
            float lowest  = share.getLowestPrice();
            float step    = (float)((highest - lowest) / 12);

            mBlocks.removeAllElements();

            int i = 0;

            for (i = 0; i < 12; i++)
            {
                vBlock v = new vBlock();
                v.beginPrice = (int)(lowest + i * step);
                v.endPrice   = (int)(lowest + (i + 1) * step);
                v.price      = (int)(v.beginPrice + step / 2);

                mBlocks.addElement(v);
            }

            for (int j = share.mBeginIdx; j <= share.mEndIdx; j++)
            {
                float  price = share.getClose(j);
                vBlock v     = getvBlock(price);
                if (v != null)
                {
                    int signal = 1;
                    if (j < share.mEndIdx)
                    {
                        signal = (share.getClose(j) < share.getClose(j + 1)) ? 1 : -1;
                    }

                    if (signal > 0)
                    {
                        v.positiveVolume += share.getVolume(j);
                    }
                    else
                    {
                        v.negativeVolume += share.getVolume(j);
                    }
                }
            }
            //==========================================
            mCurrentShare = share;
        }
コード例 #2
0
        vBlock getvBlock(float price)
        {
            for (int i = 0; i < mBlocks.size(); i++)
            {
                vBlock v = (vBlock)mBlocks.elementAt(i);
                if (v.beginPrice <= price && price <= v.endPrice)
                {
                    return(v);
                }
            }

            return(null);
        }