Example #1
0
        void drawChart(xGraphics g, int y, int h)
        {
            pricesToXYs(mPrices, mCandleCnt, mChartXYs, mTimes, y, h);

            g.setColor(0xffffffff);
            g.drawLines(mChartXYs, mCandleCnt);
        }
Example #2
0
        void drawChartAroon(xGraphics g)
        {
            int idx      = 0;
            int maxPrice = 80;

            if (detectShareCursorChanged())
            {
                Share s = getShare();
                s.calcARoon(mAroonUp, mAroonDown, mAroonOscillator, (int)mContext.mOptAroonPeriod);

                mAroonUpXY         = allocMem(mAroonUpXY, mChartLineLength * 2);
                mAroonDownXY       = allocMem(mAroonDownXY, mChartLineLength * 2);
                mAroonOscillatorXY = allocMem(mAroonOscillatorXY, mChartLineLength * 2);

                pricesToYs(mAroonUp, s.mBeginIdx, mAroonUpXY, mChartLineLength, 0, 100);
                pricesToYs(mAroonDown, s.mBeginIdx, mAroonDownXY, mChartLineLength, 0, 100);
            }

            if (mShouldDrawGrid)
            {
                drawGrid(g);
            }

            String[] ss  = { "30", "50", "70" };
            float[]  tmp = { 30, 50, 70 };
            pricesToYs(tmp, 0, mPricelines, 3, 0, 100);
            for (int i = 0; i < 3; i++)
            {
                g.setColor(C.COLOR_FADE_YELLOW);
                g.drawLine(0, mPricelines[2 * i + 1], getW() - 34, mPricelines[2 * i + 1]);
                g.setColor(C.COLOR_FADE_YELLOW0);
                g.drawString(mFont, ss[i], getW() - 8, mPricelines[2 * i + 1], xGraphics.RIGHT | xGraphics.VCENTER);
            }

            g.setColor(C.COLOR_GREEN_DARK);
            g.drawLines(mAroonUpXY, mChartLineLength, mLineThink);

            g.setColor(C.COLOR_MAGENTA);
            g.drawLines(mAroonDownXY, mChartLineLength, mLineThink);

            //        g.setColor(C.COLOR_WHITE);
            //        g.drawLines(mAroonOscillatorXY, mChartLineLength, 2.0f);

            mMouseTitle = null;//"" + (int)yToPrice(mLastY, 0, 100);

            renderCursor(g);
        }
Example #3
0
        public override void render(xGraphics g)
        {
            if (detectShareCursorChanged())
            {
                mHi = -1000000;
                mLo = 1000000;
                Share s = getShare();

                int period = (int)mContext.mOptCFMPeriod;

                s.calcCFM(period, mCFM);

                for (int i = s.mBeginIdx; i < s.mEndIdx; i++)
                {
                    if (mCFM[i] > mHi)
                    {
                        mHi = mCFM[i];
                    }
                    if (mCFM[i] < mLo)
                    {
                        mLo = mCFM[i];
                    }
                }
                mChartLineXY = allocMem(mChartLineXY, mChartLineLength * 2);

                pricesToYs(mCFM, s.mBeginIdx, mChartLineXY, mChartLineLength, mLo, mHi);
            }

            if (mShouldDrawGrid)
            {
                drawGrid(g);
            }

            String[] ss  = { "-0.2", "-0.1", "0.0", "0.1", "0.2" };
            float[]  tmp = { -0.2f, -0.1f, 0.0f, 0.1f, 0.2f };
            pricesToYs(tmp, 0, mPricelines, 5, mLo, mHi);

            for (int i = 0; i < 5; i++)
            {
                g.setColor(C.COLOR_FADE_YELLOW);
                g.drawLine(0, mPricelines[2 * i + 1], getW() - 34, mPricelines[2 * i + 1]);
                g.setColor(C.COLOR_FADE_YELLOW0);
                g.drawString(mFont, ss[i], getW() - 8, mPricelines[2 * i + 1], xGraphics.VCENTER | xGraphics.RIGHT);
            }

            g.setColor(C.COLOR_GREEN_DARK);
            g.drawLines(mChartLineXY, mChartLineLength, mLineThink);

            fillColorGreen(g, mChartLineXY, mChartLineLength, mPricelines[5]);
            fillColorRed(g, mChartLineXY, mChartLineLength, mPricelines[5]);

            mMouseTitle = null;//"" + (int)yToPrice(mLastY, 0, 100);

            renderCursor(g);
        }
Example #4
0
        void test(xGraphics g)
        {
            g.setColor(C.COLOR_RED);

            g.drawLineDotHorizontal(10, 10, 100, 100);

            g.setColor(C.COLOR_MAGENTA);
            g.fillRect(30, 40, 15, 15);

            g.setColor(C.COLOR_GREEN);
            g.drawString(mContext.getFontText(), "This is a realtime chart", 100, 10, 0);

            short[] path = { 10, 20, 35, 20, 48, 30, 35, 35 };
            g.setColor(C.COLOR_BLUE);
            g.fillShapes(path, 4);
            g.drawLines(path, 4);
        }
Example #5
0
        protected void drawChartAroonOscillator(xGraphics g)
        {
            if (detectShareCursorChanged())
            {
                Share s = getShare();
                s.calcARoon(mAroonUp, mAroonDown, mAroonOscillator, (int)mContext.mOptAroonPeriod);

                mAroonOscillatorXY = allocMem(mAroonOscillatorXY, mChartLineLength * 2);

                pricesToYs(mAroonOscillator, s.mBeginIdx, mAroonOscillatorXY, mChartLineLength, -100, 100);
            }

            if (mShouldDrawGrid)
            {
                drawGrid(g);
            }

            String[] ss  = { "-50", "0", "50" };
            float[]  tmp = { -50, 0, 50 };
            pricesToYs(tmp, 0, mPricelines, 3, -100, 100);
            for (int i = 0; i < 3; i++)
            {
                g.setColor(C.COLOR_FADE_YELLOW);
                g.drawLine(0, mPricelines[2 * i + 1], getW() - 34, mPricelines[2 * i + 1]);
                g.setColor(C.COLOR_FADE_YELLOW0);
                g.drawString(mFont, ss[i], getW() - 8, mPricelines[2 * i + 1], xGraphics.RIGHT | xGraphics.VCENTER);
            }

            fillColorGreen(g, mAroonOscillatorXY, mChartLineLength, mPricelines[3]);
            fillColorRed(g, mAroonOscillatorXY, mChartLineLength, mPricelines[3]);

            g.setColor(C.COLOR_YELLOW);
            g.drawLines(mAroonOscillatorXY, mChartLineLength, 2.0f);

            mMouseTitle = null;//"" + (int)yToPrice(mLastY, 0, 100);

            renderCursor(g);
        }
        void _renderToView(String code, xGraphics g, Rectangle rc)
        {
            daysRange        = 3 * 26;
            mChartLineLength = daysRange + 1;

            rcView = rc;

            //===================================
            candleCount = Context.getInstance().mShareManager.loadShareFromCommon(code, true, closes, opens, highs, lows, dates, volumes, daysRange);
            if (candleCount < 3)
            {
                return;
            }

            calcHiLo(closes, candleCount);

            endIdx   = candleCount - 1;
            beginIdx = endIdx - daysRange;
            if (beginIdx < 0)
            {
                beginIdx = 0;
            }
            //-------------------
            float lineThink = 1.5f;

            mChartLineLength = endIdx - beginIdx + 1;

            //  render volume
            renderVolume(g);

            //  color index
            g.setColor(C.COLOR_GRAY_LIGHT);

            pricesToYs(closes, beginIdx, mChartLineXY, mChartLineLength, priceMin, priceMax);

            g.drawLines(mChartLineXY, mChartLineLength, lineThink);
        }
Example #7
0
        public override void render(xGraphics g)
        {
            int mH = getH();
            int mW = getW();

            if (isHiding())
            {
                return;
            }
            Share share = getShare(3);

            if (share == null)
            {
                return;
            }
            if (detectShareCursorChanged())
            {
                share.calcStochastic();

                int newSize = mChartLineLength * 2;
                mK = allocMem(mK, newSize);
                mD = allocMem(mD, newSize);

                if (mIsFastStochastic)
                {
                    pricesToYs(share.pStochasticFastK, share.mBeginIdx, mK, mChartLineLength, 0, 100);
                    pricesToYs(share.pStochasticFastD, share.mBeginIdx, mD, mChartLineLength, 0, 100);
                }
                else
                {
                    pricesToYs(share.pStochasticSlowK, share.mBeginIdx, mK, mChartLineLength, 0, 100);
                    pricesToYs(share.pStochasticSlowD, share.mBeginIdx, mD, mChartLineLength, 0, 100);
                }

                float[] tmp = { 20, 50, 80 };
                pricesToYs(tmp, 0, mPricelines, 3, 0, 100);
            }

            if (mChartLineLength == 0)
            {
                return;
            }

            //========================
            if (mShouldDrawGrid)
            {
                drawGrid(g);
            }
            //===============================================
            String[] ss = { "20", "50", "80" };

            for (int i = 0; i < 3; i++)
            {
                g.setColor(C.COLOR_FADE_YELLOW);
                g.drawLine(0, mPricelines[2 * i + 1], getW() - 34, mPricelines[2 * i + 1]);
                g.setColor(C.COLOR_FADE_YELLOW0);
                g.drawString(mFont, ss[i], getW() - 3, mPricelines[2 * i + 1], xGraphics.VCENTER | xGraphics.RIGHT);
            }

            //  fast: pink
            g.setColor(0xc0ff00ff);
            g.drawLines(mK, mChartLineLength, 1.5f);

            //  slow:
            g.setColor(0xc0f08000);
            g.drawLines(mD, mChartLineLength, 1.5f);

            mMouseTitle = "" + (int)yToPrice(mLastY, 0, 100);
            renderCursor(g);

            renderDrawer(g);
        }
Example #8
0
        public override void render(xGraphics g)
        {
            int mH = getH();
            int mW = getW();

            if (isHiding())
            {
                return;
            }
            Share share = getShare(3);

            if (share == null)
            {
                return;
            }
            if (detectShareCursorChanged())
            {
                share.calcIchimoku();

                int newSize = mChartLineLength * 2;
                mLineTenkansen = allocMem(mLineTenkansen, newSize);
                mLineKijunsen  = allocMem(mLineKijunsen, newSize);
                mLineChikou    = allocMem(mLineChikou, newSize);
                mLineSpanA     = allocMem(mLineSpanA, newSize + 1000);
                mLineSpanB     = allocMem(mLineSpanB, newSize + 1000);

                int idx = share.mBeginIdx;
                pricesToYs(share.pTenkansen, idx, mLineTenkansen, mChartLineLength, false);
                pricesToYs(share.pKijunsen, idx, mLineKijunsen, mChartLineLength, false);
                pricesToYs(share.pChikouSpan, idx, mLineChikou, mChartLineLength, false);
                //  correct the chikou length
                int chikouCnt = share.getCandleCount() - (int)mContext.mOptIchimokuTime2;
                mChikouLineLength = mChartLineLength;
                if (idx + mChikouLineLength > chikouCnt)
                {
                    mChikouLineLength = chikouCnt - idx;
                }

                int kumoLen = mChartLineLength + (int)mContext.mOptIchimokuTime2;    //  shift 26 days ahead
                pricesToYs(share.pSpanA, idx, mLineSpanA, kumoLen, false);
                pricesToYs(share.pSpanB, idx, mLineSpanB, kumoLen, false);

                //  kumo cloud
                uint[]     colors  = { 0x40f06070, 0x40f0f0f0 }; //  bronw/white
                int        t       = mLineSpanA[1] > mLineSpanB[1] ? 0 : 1;
                xVectorInt vinters = new xVectorInt(100);
                xVectorInt vcolors = new xVectorInt(100);
                vinters.addElement(0);
                vcolors.addElement((int)colors[t]);

                for (int i = 0; i < kumoLen; i++)
                {
                    int j = 2 * i + 1;
                    if (t == 0)
                    {
                        if (mLineSpanA[j] < mLineSpanB[j])
                        {
                            t = 1 - t;
                            vinters.addElement(i);
                            vcolors.addElement((int)colors[t]);
                        }
                    }
                    else if (t == 1)
                    {
                        if (mLineSpanA[j] > mLineSpanB[j])
                        {
                            t = 1 - t;
                            vinters.addElement(i);
                            vcolors.addElement((int)colors[t]);
                        }
                    }
                }
                //===========================
                vinters.addElement(kumoLen - 1);
                vcolors.addElement(0);  //  dont care this time
                clearKumoCloud();
                //  create kumo cloud
                for (int i = 1; i < vinters.size(); i++)
                {
                    int     b     = vinters.elementAt(i - 1);
                    int     e     = vinters.elementAt(i);
                    short[] cloud = new short[((e - b + 10) * 4)];

                    int j = 0;
                    for (int k = b; k <= e; k++)
                    {
                        cloud[j++] = mLineSpanA[2 * k];
                        cloud[j++] = mLineSpanA[2 * k + 1];
                    }
                    cloud[j++] = mLineSpanB[2 * e];
                    cloud[j++] = mLineSpanB[2 * e + 1];
                    for (int k = e; k >= b; k--)
                    {
                        cloud[j++] = mLineSpanB[2 * k];
                        cloud[j++] = mLineSpanB[2 * k + 1];
                    }

                    mKumoCloud.addElement(cloud);
                    mKumoCloudItemLength.addElement(j / 2);
                    mKumoCloudColor.addElement(vcolors.elementAt(i - 1));
                }
            }

            if (mChartLineLength == 0)
            {
                return;
            }

            //===============================================
            //  tenkansen: pink
            g.setColor(0xc0ff00ff);
            g.drawLines(mLineTenkansen, mChartLineLength);

            //  kijunsen:
            g.setColor(0xc00050ff);
            g.drawLines(mLineKijunsen, mChartLineLength);

            //  chikou
            if (mChikouLineLength > 0)
            {
                g.setColor(0xc0907070);
                g.drawLines(mLineChikou, mChikouLineLength);
            }
            //  spanA
            g.setColor(0xb000a050);
            g.drawLines(mLineSpanA, mChartLineLength + (int)mContext.mOptIchimokuTime2);
            //  spanB
            g.setColor(0xb0ff0000);
            g.drawLines(mLineSpanB, mChartLineLength + (int)mContext.mOptIchimokuTime2);

            //  kumo cloud
            for (int i = 0; i < mKumoCloud.size(); i++)
            {
                short[] p = (short[])mKumoCloud.elementAt(i);
                if (p != null)
                {
                    g.setColor(mKumoCloudColor.elementAt(i));
                    g.fillShapes(p, mKumoCloudItemLength.elementAt(i));
                }
            }

            //  info
            String        sz;
            StringBuilder sb = Utils.sb;

            sb.Length = 0;
            int cur = share.getCursor();
            int y   = 24;

            if (mShouldDrawValue && cur >= 0 && cur < share.getCandleCount())
            {
                g.setColor(0x60404040);
                if (cur - mContext.mOptIchimokuTime2 > 0)
                {
                    int x0 = candleToX(cur - mContext.mOptIchimokuTime2);
                    g.drawVerticalLine(x0, 0, getH());
                }
                int x1 = candleToX(cur + mContext.mOptIchimokuTime2);
                g.drawVerticalLine(x1, 0, getH());

                //==========draw 2 shadow vertical
                g.setColor(0xffffa000);
                sb.AppendFormat("Ichi({0},{1},{2})", (int)mContext.mOptIchimokuTime1, (int)mContext.mOptIchimokuTime2, (int)mContext.mOptIchimokuTime3);
                sz = sb.ToString();
                g.drawString(mFont, sz, 130, y, 0);
                int x = 150 + g.getStringWidth(mFont, sz) + 10;

                String sz1;
                sz1 = formatPrice(share.pTenkansen[cur]);
                //  tenkansen
                g.setColor(0xc0ff00ff);
                sb.Length = 0;
                sb.AppendFormat("Tenkan: {0}", sz1);
                sz = sb.ToString();
                g.drawString(mFont, sz, x, y, 0);
                x += g.getStringWidth(mFont, sz) + 10;
                //  kijun
                g.setColor(0xc00050ff);
                sz1       = formatPrice(share.pKijunsen[cur]);
                sb.Length = 0;
                sb.AppendFormat("Kijun: {0}", sz1);
                sz = sb.ToString();
                g.drawString(mFont, sz, x, y, 0);
                x += g.getStringWidth(mFont, sz) + 10;
                //  chikou
                g.setColor(0xc0a0a0a0);
                float chikou = 0;
                if (cur < share.getCandleCount() - mContext.mOptIchimokuTime2)
                {
                    chikou = share.pChikouSpan[cur];
                }
                sz1       = formatPrice(chikou);
                sb.Length = 0;
                sb.AppendFormat("Chikou: {0}", sz1);
                sz = sb.ToString();
                g.drawString(mFont, sz, x, y, 0);
                x += g.getStringWidth(mFont, sz) + 10;
                //  spanA
                g.setColor(0xff00a050);
                sz1       = formatPrice(share.pSpanA[cur]);
                sb.Length = 0;
                sb.AppendFormat("SpanA: {0}", sz1);
                sz = sb.ToString();
                g.drawString(mFont, sz, x, y, 0);
                x += g.getStringWidth(mFont, sz) + 10;
                //  spanB
                g.setColor(0xb0ff0000);
                sz1       = formatPrice(share.pSpanB[cur]);
                sb.Length = 0;
                sb.AppendFormat("SpanB: {0}", sz1);
                sz = sb.ToString();
                g.drawString(mFont, sz, x, y, 0);
            }
        }
Example #9
0
        public override void render(xGraphics g)
        {
            Share share = getShare(3);

            if (share == null)
            {
                return;
            }
            if (detectShareCursorChanged())
            {
                bankerXY    = allocMem(bankerXY, mChartLineLength * 2);
                bankerXYSMA = allocMem(bankerXYSMA, mChartLineLength * 2);
                hotmoneyXY  = allocMem(hotmoneyXY, mChartLineLength * 2);

                // banker
                int   baseBanker        = (int)getConfigValue(true, FIELD_BASE);
                int   periodBanker      = (int)getConfigValue(true, FIELD_PERIOD);
                float sensitivityBanker = getConfigValue(true, FIELD_SENSITIVITY);

                //  hot money
                int   baseHM        = (int)getConfigValue(false, FIELD_BASE);
                int   periodHM      = (int)getConfigValue(false, FIELD_PERIOD);
                float sensitivityHM = getConfigValue(false, FIELD_SENSITIVITY);

                int newChecksum = 0;
                //-----------------------
                newChecksum = share.getID() + baseBanker * 100 + periodBanker * 99 + (int)(sensitivityBanker * 1000)
                              + baseHM * 88 + periodHM * 77 + (int)(sensitivityHM * 2000);
                int checkSumData = share.getCandleCnt();
                for (int i = 0; i < 10; i++)
                {
                    checkSumData += (int)(share.getClose(share.getCandleCnt() - 1 - i) * 10);
                }
                newChecksum = newChecksum + checkSumData;
                //-----------------------
                if (checkSum != newChecksum)
                {
                    checkSum = newChecksum;

                    rsi_function(share, sensitivityBanker, periodBanker, baseBanker, rsiBanker);
                    Share.SMA(rsiBanker, 0, share.getCandleCnt(), 5, rsiBankerSMA);

                    rsi_function(share, sensitivityHM, periodHM, baseHM, rsiHotmoney);
                }

                //  banker
                pricesToYs(rsiBanker, share.mBeginIdx, bankerXY, mChartLineLength, 0, 20);

                //  sma of banker
                pricesToYs(rsiBankerSMA, share.mBeginIdx, bankerXYSMA, mChartLineLength, 0, 20);

                //  hot money
                pricesToYs(rsiHotmoney, share.mBeginIdx, hotmoneyXY, mChartLineLength, 0, 20);
            }

            String[] ss  = { "5", "10", "15" };
            float[]  tmp = { 5, 10, 15 };
            pricesToYs(tmp, 0, mPricelines, 3, 0, 20);

            for (int i = 0; i < 3; i++)
            {
                g.setColor(C.COLOR_FADE_YELLOW);
                g.drawLine(0, mPricelines[2 * i + 1], getW() - 34, mPricelines[2 * i + 1]);

                g.setColor(C.COLOR_FADE_YELLOW0);
                g.drawString(mFont, ss[i], getW() - 8, mPricelines[2 * i + 1], xGraphics.VCENTER | xGraphics.RIGHT);
            }

            int mY = 0;
            int mX = 0;

            //  bars
            mVolumeBarW = (((float)getDrawingW() / mChartLineLength) * 2.0f / 3);
            for (int i = 0; i < mChartLineLength; i++)
            {
                //  retail
                g.setColor(themeDark()?0xff005e07:C.COLOR_GREEN_DARK);

                float x = bankerXY[i * 2] - mVolumeBarW / 2;
                float y = mY + getMarginY();

                g.fillRectF(x, y, mVolumeBarW, getDrawingH());

                //  hot money
                g.setColor(themeDark()?0xffd8c200:C.COLOR_YELLOW);
                //y = mY + getMarginY() + getDrawingH() - rsiHotMoneyXY[2*i+1];
                y = hotmoneyXY[2 * i + 1];
                g.fillRectF(x, y, mVolumeBarW, mY + getMarginY() + getDrawingH() - y);

                //  banker
                g.setColor(themeDark()?0xffff0000:C.COLOR_RED);
                //y = mY + getMarginY() + getDrawingH() - rsiBankerXY[2*i+1];
                y = bankerXY[2 * i + 1];
                g.fillRectF(x, y, mVolumeBarW, mY + getMarginY() + getDrawingH() - y);
            }

            //  sma of banker
            g.setColor(C.COLOR_BLUE_LIGHT);// colorSMAOfIndicator());
            g.drawLines(bankerXYSMA, mChartLineLength, 1.0f);

            mMouseTitle = null;//"" + (int)yToPrice(mLastY, 0, 100);

            renderCursor(g);
        }
Example #10
0
        public override void render(xGraphics g)
        {
            if (isHiding())
            {
                return;
            }
            if (getShare(3) == null)
            {
                return;
            }
            Share share = getShare();
            int   mX    = 0;
            int   mY    = 0;

            Utils.trace(String.Format("volume render: {0}", getStartX()));

            if (detectShareCursorChanged())
            {
                mHighestVolume = "";
                if (mChartLineXY == null)
                {
                    mChartLineXY = new short[2 * MAX_DRAW_POINT];
                }

                //	get biggest volume
                biggest = 0;
                lowest  = -1;
                int vol;
                int i, j;
                for (i = share.mBeginIdx; i <= share.mEndIdx; i++)
                {
                    vol = share.getVolume(i);
                    if (lowest == -1)
                    {
                        lowest = vol;
                    }
                    if (biggest < vol)
                    {
                        biggest = vol;
                    }
                    if (lowest > vol)
                    {
                        lowest = vol;
                    }
                }

                if (biggest == 0)
                {
                    return;
                }

                StringBuilder sb = Utils.sb;
                sb.Length = 0;

                lowest -= 1000;

                if (lowest < 0)
                {
                    lowest = 0;
                }

                if (biggest < 1000)
                {
                    sb.Append(biggest);
                }
                else if (biggest < 1000000)
                {
                    sb.AppendFormat("{0}KB", (int)(biggest / 1000));
                }
                else
                {
                    sb.AppendFormat("{0}M", (int)(biggest / 1000000));
                }

                mHighestVolume = sb.ToString();

                lowest /= 4;

                double ry = (float)getDrawingH() / (biggest - lowest);
                double rw = (float)getDrawingW() / mChartLineLength;
                mVolumeBarW = (int)(((float)getDrawingW() / mChartLineLength) * 2.0f / 3);

                if (mVolumeBarW < 1)
                {
                    mVolumeBarW = 1;
                }
                float volumeBarWHalf = mVolumeBarW / 2;
                int   vH             = 0;
                int   vL             = 0xffffff;
                for (i = 0; i < mChartLineLength; i++)
                {
                    j = (i + share.mBeginIdx);
                    mChartLineXY[i * 2]     = (short)(mX + CHART_BORDER_SPACING_X + i * rw + getStartX() - volumeBarWHalf); //	x
                    mChartLineXY[i * 2 + 1] = (short)(mY + getMarginY() + getDrawingH() - (share.getVolume(j) - lowest) * ry);

                    if (share.mCVolume[j] > vH)
                    {
                        vH = share.mCVolume[j];
                    }
                    if (share.mCVolume[j] < vL)
                    {
                        vL = share.mCVolume[j];
                    }
                }

                //==========================
                mSMAVolumeXY = allocMem(mSMAVolumeXY, share.getCandleCount() * 2);
                share.calcSMAVolume(0, share.getCandleCount());
                mCurrentShare = share;

                pricesToYs(share.pSMAVolume, share.mBeginIdx, mSMAVolumeXY, mChartLineLength, vL, vH);
            }

            if (mShouldDrawGrid)
            {
                drawGrid(g);
            }

            //g.setColor(0xffff00ff);
            //g.drawLine(0, 150, getW(), 150);

            g.setColor(0xff00ff00);
            int tmp = mY + getH() - getMarginY();

            for (int i = 0; i < mChartLineLength; i++)
            {
                if (share.mBeginIdx + i > 0)
                {
                    if (share.getClose(share.mBeginIdx + i) > share.getClose(share.mBeginIdx + i - 1))
                    {
                        g.setColor(0xff00c000);
                    }
                    else if (share.getClose(share.mBeginIdx + i) < share.getClose(share.mBeginIdx + i - 1))
                    {
                        g.setColor(0xffa00000);
                    }
                    else
                    {
                        g.setColor(0xffa08000);
                    }
                }
                g.fillRectF(mChartLineXY[2 * i], mChartLineXY[2 * i + 1], mVolumeBarW, tmp - mChartLineXY[2 * i + 1]);
            }

            //  sma
            g.setColor(C.COLOR_ORANGE);
            g.drawLines(mSMAVolumeXY, mChartLineLength);

            g.setColor(C.COLOR_GRAY_LIGHT);
            g.drawString(mFont, mHighestVolume, getW() - 8, 0, xGraphics.RIGHT | xGraphics.TOP);
            g.drawString(mFont, "0", getW() - 8, getH(), xGraphics.RIGHT | xGraphics.BOTTOM);

            //  calc mMouseTitle
            mMouseTitle = Utils.formatNumber((int)yToPrice(mLastY, lowest, biggest));

            renderCursor(g);
        }
Example #11
0
        void drawComparativeCRSPercent(xGraphics g)
        {
            Share share = getShare();

            if (detectShareCursorChanged())
            {
                loadSavedBase();
                share.calcRSPerformance(baseShare(), mPeriod, baseMAPeriod1, baseMAPeriod2);

                mChartLineXY = allocMem(mChartLineXY, mChartLineLength * 2);

                float min = 0xffffff;
                float max = -0xffffff;

                for (int i = share.mBeginIdx; i <= share.mEndIdx; i++)
                {
                    if (share.pCRS_Percent[i] > max)
                    {
                        max = share.pCRS_Percent[i];
                    }
                    if (share.pCRS_Percent[i] < min)
                    {
                        min = share.pCRS_Percent[i];
                    }
                }

                float dis = (max - min);
                priceValuesCnt = 4;
                for (int i = 0; i < priceValuesCnt; i++)
                {
                    priceValues[i] = min + (i + 0.5f) * (dis / 4);
                }

                pricesToYs(priceValues, 0, mPricelines, priceValuesCnt, min, max);

                pricesToYs(share.pCRS_Percent, share.mBeginIdx, mChartLineXY, mChartLineLength, min, max);

                float[] tmp = { 0 };
                pricesToYs(tmp, 0, mPricelines, 1, min, max);

                if (baseMAPeriod1 > 0)
                {
                    mChartEMA1 = allocMem(mChartEMA1, mChartLineLength * 2);

                    pricesToYs(share.pCRS_MA1_Percent, share.mBeginIdx, mChartEMA1, mChartLineLength, min, max);
                }
                if (baseMAPeriod2 > 0)
                {
                    mChartEMA2 = allocMem(mChartEMA2, mChartLineLength * 2);

                    pricesToYs(share.pCRS_MA2_Percent, share.mBeginIdx, mChartEMA2, mChartLineLength, min, max);
                }
            }

            if (mChartLineLength == 0)
            {
                return;
            }

            //========================
            if (mShouldDrawGrid)
            {
                drawGrid(g);
            }
            //===============================================
            for (int i = 0; i < priceValuesCnt; i++)
            {
                String priceS = String.Format("{0:F3}", priceValues[i]);
                g.setColor(C.COLOR_FADE_YELLOW);
                g.drawLine(0, mPricelines[2 * i + 1], getW() - 34, mPricelines[2 * i + 1]);
                g.setColor(C.COLOR_FADE_YELLOW0);
                g.drawString(mFont, priceS, getW() - 8, mPricelines[2 * i + 1], xGraphics.VCENTER | xGraphics.RIGHT);
            }
            //  CRS
            g.setColor(0xffffffff);
            g.drawLines(mChartLineXY, mChartLineLength, 1.5f);

            if (baseMAPeriod1 > 0)
            {
                g.setColor(C.COLOR_GREEN);
                g.drawLines(mChartEMA1, mChartLineLength, 1.0f);
            }
            if (baseMAPeriod2 > 0)
            {
                g.setColor(C.COLOR_YELLOW);
                g.drawLines(mChartEMA2, mChartLineLength, 1.0f);
            }

            renderCursor(g);

            renderDrawer(g);
        }
Example #12
0
        public override void render(xGraphics g)
        {
            int mH = getH();
            int mW = getW();

            if (isHiding())
            {
                return;
            }
            Share share = getShare();

            if (share == null)
            {
                return;
            }

            int idx      = 0;
            int maxPrice = 80;

            if (detectShareCursorChanged())
            {
                share.calcADX();

                int newSize = mChartLineLength * 2;
                mChartLineXY = allocMem(mChartLineXY, newSize);
                mLineMDI     = allocMem(mLineMDI, newSize);
                mLinePDI     = allocMem(mLinePDI, newSize);

                idx = share.mBeginIdx;
                pricesToYs(share.pPLUS_DI, idx, mLinePDI, mChartLineLength, 0, maxPrice);
                pricesToYs(share.pMINUS_DI, idx, mLineMDI, mChartLineLength, 0, maxPrice);
                pricesToYs(share.pADX, idx, mChartLineXY, mChartLineLength, 0, maxPrice);

                float ry = (float)getDrawingH() / maxPrice;
                mY20 = (int)(getMarginY() + getDrawingH() - 20 * ry);
                mY40 = (int)(getMarginY() + getDrawingH() - 40 * ry);
            }

            if (mChartLineLength == 0)
            {
                return;
            }

            if (mShouldDrawGrid)
            {
                drawGrid(g);
            }
            //===============================================
            g.setColor(C.COLOR_FADE_YELLOW);
            g.drawHorizontalLine(0, mY20, mW - 34);
            g.drawHorizontalLine(0, mY40, mW - 34);

            g.setColor(C.COLOR_FADE_YELLOW0);
            g.drawString(mFont, "20", 0 + mW - 2, mY20, xGraphics.RIGHT | xGraphics.VCENTER);
            g.drawString(mFont, "40", 0 + mW - 2, mY40, xGraphics.RIGHT | xGraphics.VCENTER);

            g.setColor(0xffffffff);

            g.drawLines(mChartLineXY, mChartLineLength, 2.0f);

            g.setColor(0xff00ff00);
            g.drawLines(mLinePDI, mChartLineLength, 1.0f);

            g.setColor(0xffff0000);
            g.drawLines(mLineMDI, mChartLineLength, 1.0f);
            //==============================
            StringBuilder sb = Utils.sb;

            sb.Length = 0;
            sb.AppendFormat("{0:F2}", (float)yToPrice(mLastY, 0, 80));
            mMouseTitle = sb.ToString();

            renderCursor(g);

            //===================
            //	bottom border
            g.setColor(0xffa0a0a0);
            g.drawHorizontalLine(0, 0, getW());

            renderDrawer(g);
        }
Example #13
0
        void drawBollingers(xGraphics g, int y, int h)
        {
            int[]   times     = mTimes;
            float[] prices    = mPrices;
            int     pricesCnt = mCandleCnt;

            if (pricesCnt <= 0)
            {
                return;
            }

            int pointCnt = 0;

            int i = 0;

            float lo     = mPriceBase - price_distance / 2;
            float hi     = mPriceBase + price_distance / 2;
            int   period = 14;

            if (pricesCnt < 30)
            {
                period = pricesCnt / 3;
            }
            if (period < 2)
            {
                period = 2;
            }
            Share.calcBollinger(prices, pricesCnt, period, 2.0f, pBBLowers, pBBUppers);

            if (mBBLowerXY == null)
            {
                mBBUpperXY = new short[20000];
                mBBLowerXY = new short[20000];
                mBBLine    = new short[40000];
            }

            pricesToXYs(pBBLowers, pricesCnt, mBBUpperXY, times, y, h);
            pricesToXYs(pBBUppers, pricesCnt, mBBLowerXY, times, y, h);

            int j = 0;

            j = 0;

            for (i = 0; i < pricesCnt; i++)
            {
                mBBLine[j++] = mBBUpperXY[2 * i];
                mBBLine[j++] = mBBUpperXY[2 * i + 1];
            }
            mBBLine[j++] = mBBUpperXY[2 * (pricesCnt - 1)];      //  x
            mBBLine[j++] = mBBLowerXY[2 * (pricesCnt - 1) + 1];  //  y
            for (i = pricesCnt - 1; i >= 0; i--)
            {
                mBBLine[j++] = mBBLowerXY[2 * i];
                mBBLine[j++] = mBBLowerXY[2 * i + 1];
            }

            pointCnt = j / 2;
            //=======river
            g.setColor(0x40F8D4CF);
            g.fillShapes(mBBLine, pointCnt);

            //===========border
            pointCnt = mTrade.getTransactionCount();
            g.setColor(0xff752922);
            g.drawLines(mBBUpperXY, pricesCnt);
            g.drawLines(mBBLowerXY, pricesCnt);
        }
Example #14
0
        override public void render(xGraphics g)
        {
            int mH = getH();
            int mW = getW();

            if (isHiding())
            {
                return;
            }
            Share share = getShare(3);

            if (share == null)
            {
                return;
            }

            int ma1 = 0;
            int ma2 = 0;

            if (detectShareCursorChanged())
            {
                share.calcWilliamR();

                mChartLineXY = allocMem(mChartLineXY, mChartLineLength * 2);

                pricesToYs(share.pWilliamR, share.mBeginIdx, mChartLineXY, mChartLineLength, -100, 0);
                float[] tmp = { -20, -50, -80 };
                pricesToYs(tmp, 0, mPricelines, 3, -100, 0);

                ma1 = GlobalData.getData().getValueInt(GlobalData.kWilliamR_MA1);
                ma2 = GlobalData.getData().getValueInt(GlobalData.kWilliamR_MA2);

                if (ma1 > 0)
                {
                    mChartEMA = allocMem(mChartEMA, mChartLineLength * 2);
                    Share.SMA(share.pWilliamR, 0, share.getCandleCount(), ma1, share.pEMAIndicator);

                    pricesToYs(share.pEMAIndicator, share.mBeginIdx, mChartEMA, mChartLineLength, -100, 0);
                }
                if (ma2 > 0)
                {
                    mChartEMA2 = allocMem(mChartEMA2, mChartLineLength * 2);
                    Share.SMA(share.pWilliamR, 0, share.getCandleCount(), ma2, share.pEMAIndicator);

                    pricesToYs(share.pEMAIndicator, share.mBeginIdx, mChartEMA2, mChartLineLength, -100, 0);
                }
            }

            if (mChartLineLength == 0)
            {
                return;
            }

            //========================
            if (mShouldDrawGrid)
            {
                drawGrid(g);
            }
            //===============================================
            String[] ss = { "-20", "-50", "-80" };

            g.setColor(C.COLOR_GRAY_DARK);
            for (int i = 0; i < 3; i++)
            {
                g.setColor(C.COLOR_GRAY_DARK);
                g.drawLine(0, mPricelines[2 * i + 1], getW() - 34, mPricelines[2 * i + 1]);

                g.setColor(C.COLOR_FADE_YELLOW0);
                g.drawString(mFont, ss[i], getW() - 3, mPricelines[i * 2 + 1], xGraphics.VCENTER | xGraphics.RIGHT);
            }

            //  williamR
            g.setColor(0xffff8000);
            g.drawLines(mChartLineXY, mChartLineLength, 1.5f);

            ma1 = GlobalData.getData().getValueInt(GlobalData.kWilliamR_MA1);
            ma2 = GlobalData.getData().getValueInt(GlobalData.kWilliamR_MA2);
            if (ma1 > 0)
            {
                g.setColor(C.COLOR_MAGENTA);
                g.drawLines(mChartEMA, mChartLineLength, 1.0f);
            }
            if (ma2 > 0)
            {
                g.setColor(C.COLOR_CYAN);
                g.drawLines(mChartEMA2, mChartLineLength, 1.0f);
            }

            renderCursor(g);
        }
Example #15
0
        public override void render(xGraphics g)
        {
            int mH = getH();
            int mW = getW();

            if (isHiding())
            {
                return;
            }
            Share share = getShare(3);

            if (share == null)
            {
                return;
            }
            if (detectShareCursorChanged())
            {
                share.calcOBV();

                mChartLineXY = allocMem(mChartLineXY, mChartLineLength * 2);

                float min = 0xffffff;
                float max = -0xffffff;

                for (int i = share.mBeginIdx; i <= share.mEndIdx; i++)
                {
                    if (share.pOBV[i] > max)
                    {
                        max = share.pOBV[i];
                    }
                    if (share.pOBV[i] < min)
                    {
                        min = share.pOBV[i];
                    }
                }

                pricesToYs(share.pOBV, share.mBeginIdx, mChartLineXY, mChartLineLength, min, max);

                if (mContext.mOptOBV_EMA > 0)
                {
                    mChartEMA = allocMem(mChartEMA, mChartLineLength * 2);

                    if (mContext.mOptOBV_EMA_ON[0])
                    {
                        Share.EMA(share.pOBV, share.getCandleCount(), (int)mContext.mOptOBV_EMA, share.pTMP);
                    }
                    else
                    {
                        Share.SMA(share.pOBV, 0, share.getCandleCount(), (int)mContext.mOptOBV_EMA, share.pTMP);
                    }
                    pricesToYs(share.pTMP, share.mBeginIdx, mChartEMA, mChartLineLength, min, max);
                }
            }

            if (mChartLineLength == 0)
            {
                return;
            }

            //========================
            if (mShouldDrawGrid)
            {
                drawGrid(g);
            }
            //===============================================
            //  OBV
            g.setColor(0xff00f000);
            g.drawLines(mChartLineXY, mChartLineLength, 1.5f);

            if (mContext.mOptOBV_EMA > 0)
            {
                g.setColor(C.COLOR_MAGENTA);
                g.drawLines(mChartEMA, mChartLineLength, 1.0f);
            }

            renderCursor(g);

            renderDrawer(g);
        }
Example #16
0
        public override void render(xGraphics g)
        {
            if (isHiding())
            {
                return;
            }
            if (getShare(3) == null)
            {
                return;
            }

            Share share = getShare();

            if (share == null)
            {
                return;
            }

            if (detectShareCursorChanged())
            {
                share.calcBollinger();

                mBBUpperXY = allocMem(mBBUpperXY, mChartLineLength * 2 + 10);
                mBBLowerXY = allocMem(mBBLowerXY, mChartLineLength * 2 + 10);
                mCenterXY  = allocMem(mCenterXY, mChartLineLength * 2 + 10);
                mBBLine    = allocMem(mBBLine, mChartLineLength * 4 + 10);

                pricesToYs(share.pBBUpper, share.mBeginIdx, mBBUpperXY, mChartLineLength, share.getLowestPrice(), share.getHighestPrice());
                pricesToYs(share.pBBLower, share.mBeginIdx, mBBLowerXY, mChartLineLength, share.getLowestPrice(), share.getHighestPrice());

                int j = 0;

                j = 0;

                for (int i = 0; i < mChartLineLength; i++)
                {
                    mBBLine[j++] = mBBUpperXY[2 * i];
                    mBBLine[j++] = mBBUpperXY[2 * i + 1];

                    mCenterXY[2 * i]     = mBBLowerXY[2 * i];
                    mCenterXY[2 * i + 1] = (short)((mBBUpperXY[2 * i + 1] + mBBLowerXY[2 * i + 1]) / 2);
                }
                mBBLine[j++] = mBBUpperXY[2 * (mChartLineLength - 1)];      //  x
                mBBLine[j++] = mBBLowerXY[2 * (mChartLineLength - 1) + 1];  //  y
                for (int i = mChartLineLength - 1; i >= 0; i--)
                {
                    mBBLine[j++] = mBBLowerXY[2 * i];
                    mBBLine[j++] = mBBLowerXY[2 * i + 1];
                }

                mPointCnt = j / 2;
            }

            if (mChartLineLength == 0)
            {
                return;
            }

            int mX = 0;
            int mY = 0;
            int mW = getW();
            int mH = getH();

            g.setColor(mBBColorBG);
            g.fillShapes(mBBLine, mPointCnt);

            g.setColor(0xa00080ff);
            g.drawLinesDot(mCenterXY, mChartLineLength);

            g.setColor(0xff752922);
            g.drawLines(mBBUpperXY, mChartLineLength);
            g.drawLines(mBBLowerXY, mChartLineLength);

            //=================================
            int cur = share.getCursor();

            if (mShouldDrawValue && cur >= 0 && cur < share.getCandleCount())
            {
                g.setColor(0xffffa0a0);

                String        s1 = formatPrice(share.pBBUpper[cur]);
                String        s2 = formatPrice(share.pBBLower[cur]);
                StringBuilder sb = Utils.sb;
                sb.Length = 0;
                sb.AppendFormat("BB({0},{1}) U:{2}     L:{3}", (int)mContext.mOptBBPeriod, (int)mContext.mOptBBD, s1, s2);
                s1 = sb.ToString();
                g.drawString(mFont, s1, 150, 12, 0);
            }
        }
Example #17
0
        override public void render(xGraphics g)
        {
            if (isHiding())
            {
                return;
            }


            Share share = getShare(3);

            if (share == null)
            {
                return;
            }

            int mX = 0;
            int mY = 0;

            //	update line ordinates
            if (detectShareCursorChanged() && mChartLineLength > 0)             //	share's cursor has been changed
            {
                calcZigzag();
                //=======================
                int items = (mChartLineLength + 10) * 2;

                if (items < 2 * mZigzag.size() + 100)
                {
                    items = mZigzag.size() * 2 + 100;
                }

                mZigzagPointCnt = 0;

                mChartLineXY = allocMem(mChartLineXY, items);

                mChartLineLength = 0;

                if (mZigzag != null && mZigzag.size() > 0)
                {
                    //  seek to the nearest point
                    int   i;
                    float low   = share.getLowestPrice();
                    float rY    = (float)getDrawingH() / mPriceDistance;
                    float rX    = (float)getDrawingW() / mChartLineLength;
                    int   begin = -1;
                    for (i = 0; i < mZigzag.size(); i++)
                    {
                        int idx = mZigzag.elementAt(i);
                        if (idx >= share.mBeginIdx)
                        {
                            begin = i - 1;
                            break;
                        }
                    }

                    if (begin < 0)
                    {
                        begin = 0;
                    }
                    mChartLineLength = 0;
                    for (i = begin; i < mZigzag.size(); i++)
                    {
                        int idx = mZigzag.elementAt(i);

                        mChartLineXY[2 * mZigzagPointCnt] = (short)candleToX(idx);
                        float close = share.getClose(mZigzag.elementAt(i));
                        mChartLineXY[2 * mZigzagPointCnt + 1] = (short)priceToY(close);

                        mZigzagPointCnt++;

                        if (mChartLineXY[2 * (mZigzagPointCnt - 1)] > mX + getW())
                        {
                            break;
                        }
                    }
                }
            }
            //==========draw now
            if (mZigzagPointCnt > 0)
            {
                g.setColor(C.COLOR_RED_ORANGE);
                g.drawLines(mChartLineXY, mZigzagPointCnt, 2.0f);
            }
        }
Example #18
0
        public override void render(xGraphics g)
        {
            if (isHiding())
            {
                return;
            }
            if (getShare(3) == null)
            {
                return;
            }
            if (detectShareCursorChanged())
            {
                recalcMACD();
            }

            if (mChartLineLength == 0)
            {
                return;
            }

            if (mShouldDrawGrid)
            {
                drawGrid(g);
            }

            //mOY = getH() / 2;
            g.setColor(C.COLOR_FADE_YELLOW);
            g.drawLine(0, mOY, getW() - 34, mOY);
            g.setColor(C.COLOR_FADE_YELLOW0);
            g.drawString(mFont, "0", getW() - 8, mOY, xGraphics.VCENTER | xGraphics.RIGHT);

            int hisW = (int)(((float)getDrawingW() / mChartLineLength) * 2.0f / 3);

            for (int i = 0; i < mChartLineLength; i++)
            {
                if (mHistogramH[i] > 0)
                {
                    g.setColor(0xffff0000);
                }
                else
                {
                    g.setColor(0xff00ff00);
                }
                g.fillRect(mHistogramXY[2 * i], mHistogramXY[2 * i + 1], hisW, mHistogramH[i]);
            }

            g.setColor(C.COLOR_BLUE_LIGHT);
            g.drawLines(mLineMACD, mChartLineLength, 2.0f);

            g.setColor(0xffff0000);
            g.drawLines(mLineSignal9, mChartLineLength, 1.0f);

            StringBuilder sb = Utils.sb;

            //=========================
            sb.Length = 0;
            float v = (mOY - mLastY) / ry;

            sb.AppendFormat("{0:F2}", v);

            mMouseTitle = sb.ToString();
            renderCursor(g);
            //	bottom border
            g.setColor(0xffa0a0a0);
            g.drawHorizontalLine(0, 0, getW());

            renderDrawer(g);
        }
Example #19
0
        public override void render(xGraphics g)
        {
            int mH = getH();
            int mW = getW();

            if (isHiding())
            {
                return;
            }
            Share share = getShare(3);

            if (share == null)
            {
                return;
            }
            if (detectShareCursorChanged())
            {
                int rsiPeriod   = GlobalData.getData().getValueInt(GlobalData.kStochRSIPeriod1, 14);
                int stochPeriod = GlobalData.getData().getValueInt(GlobalData.kStochRSIPeriodStock, 14);
                int smoothK     = GlobalData.getData().getValueInt(GlobalData.kStockRSISmoothK, 3);
                int smoothD     = GlobalData.getData().getValueInt(GlobalData.kStochRSISmoothD, 3);

                share.calcStochRSI(rsiPeriod, stochPeriod, smoothK, smoothD, pStochRSI, pStochRSISMA);

                mChartLineXY = allocMem(mChartLineXY, mChartLineLength * 2);

                pricesToYs(pStochRSI, share.mBeginIdx, mChartLineXY, mChartLineLength, -10, 110);
                float[] tmp = { 0, 20, 50, 80, 100 };
                pricesToYs(tmp, 0, mPricelines, 5, -10, 110);

                //  SMA
                mChartLineXY2 = allocMem(mChartLineXY2, mChartLineLength * 2);
                pricesToYs(pStochRSISMA, share.mBeginIdx, mChartLineXY2, mChartLineLength, -10, 110);
            }

            if (mChartLineLength == 0)
            {
                return;
            }

            //========================
            if (mShouldDrawGrid)
            {
                drawGrid(g);
            }
            //===============================================
            String[] ss = { "0", "20", "50", "80", "100" };

            for (int i = 0; i < 5; i++)
            {
                if (i == 0 || i == 4 || i == 2)
                {
                    g.setColor(C.COLOR_GRAY_DARK);
                    g.drawLineDotHorizontal(0, mPricelines[2 * i + 1], getW() - 44, mPricelines[2 * i + 1]);
                }
                else
                {
                    g.setColor(C.COLOR_FADE_YELLOW);
                    g.drawLine(0, mPricelines[2 * i + 1], getW() - 44, mPricelines[2 * i + 1]);
                }
                g.setColor(C.COLOR_FADE_YELLOW0);
                g.drawString(mFont, ss[i], getW() - 8, mPricelines[2 * i + 1], xGraphics.VCENTER | xGraphics.RIGHT);
            }

            //  stochRSI
            g.setColor(0xffff8000);
            g.drawLines(mChartLineXY, mChartLineLength, 1.5f);

            g.setColor(0xffb000b0);
            g.drawLines(mChartLineXY2, mChartLineLength, 1.5f);

            renderDrawer(g);

            renderCursor(g);
        }
Example #20
0
        void drawMACD(xGraphics g, int y, int h)
        {
            calcMACD();

            if (mCandleCnt < 5)
            {
                return;
            }

            //  translate to XYs
            //======================
            float lo = 1000;
            float hi = -1000;

            int i;

            float[] his = pMACDHistogram;
            for (i = 0; i < mCandleCnt; i++)
            {
                his[i] = pMACD[i] - pMACDSignal9[i];
            }
            //===========================

            float[] macd   = pMACD;
            float[] signal = pMACDSignal9;
            his = pMACDHistogram;

            int cnt = mCandleCnt;

            //	get the highest
            int   w  = getW();
            float rx = (float)w / cnt;

            //	lo/hi
            for (i = 0; i < cnt; i++)
            {
                if (macd[i] > hi)
                {
                    hi = macd[i];
                }
                if (macd[i] < lo)
                {
                    lo = macd[i];
                }
            }
            for (i = 0; i < cnt; i++)
            {
                if (signal[i] > hi)
                {
                    hi = signal[i];
                }
                if (signal[i] < lo)
                {
                    lo = signal[i];
                }
            }

            if (hi < 0)
            {
                hi = 0;
            }
            if (lo < 0)
            {
                lo = -lo;
            }

            float double_hi = Utils.ABS_FLOAT(hi) > Utils.ABS_FLOAT(lo) ? hi : lo;// hi + lo;

            double_hi = 2 * Utils.ABS_FLOAT(double_hi);

            int   minHistoH   = 9;
            int   signalDrawH = h - 2 * minHistoH;
            int   OY          = y + h / 2;
            float ry          = 0;

            if (double_hi != 0)
            {
                OY = y + h / 2;
                ry = (float)signalDrawH / double_hi;
            }

            //	make sure all macd is now > 0 && < 100
            for (i = 0; i < cnt; i++)
            {
                mLineMACD[2 * i + 1]    = (short)(OY - macd[i] * ry);
                mLineSignal9[2 * i + 1] = (short)(OY - signal[i] * ry);
            }

            //	cnt == CHART_W
            int max_time = getMaxTimeOfChart();
            int timeb    = Utils.EXTRACT_HOUR(mTimes[0]) * 3600
                           + Utils.EXTRACT_MINUTE(mTimes[0]) * 60
                           + Utils.EXTRACT_SECOND(mTimes[0]);

            rx = (float)getW() / max_time;
            for (i = 0; i < cnt; i++)
            {
                int time = timeToSeconds(mTimes[i]);
                time -= timeb;

                mLineMACD[2 * i]    = (short)(time * rx);
                mLineSignal9[2 * i] = mLineMACD[2 * i];
            }

            //	histogram
            hi = 0;
            for (i = 0; i < cnt; i++)
            {
                if (Utils.ABS_FLOAT(his[i]) > hi)
                {
                    hi = Utils.ABS_FLOAT(his[i]);
                }
            }
            //	int deltaY = 0;//deltaLoHi*mDrawingH/double_hi;
            double_hi = 2 * hi;
            //	double_hi	==	100 pixels
            int   halfH = h / 2;
            float hry   = 0;

            if (hi != 0)
            {
                hry = (float)halfH / hi;//double_hi;
            }
            i = 0;
            int drawW = 0;

            for (i = 0; i < cnt; i++)
            {
                if (double_hi != 0)
                {
                    mHistogramH[i] = (short)(-his[i] * ry);
                }
                else
                {
                    mHistogramH[i] = 0;
                }

                if (mHistogramH[i] == 0)
                {
                    if (his[i] > 0)
                    {
                        mHistogramH[i] = -1;
                    }
                    else
                    {
                        mHistogramH[i] = 1;
                    }
                }
                int time = timeToSeconds(mTimes[i]);
                time -= timeb;

                mHistogramXY[2 * i] = (short)(time * rx);
                drawW = mHistogramXY[2 * i];
                mHistogramXY[2 * i + 1] = (short)OY;
            }

            // ===========================================================
            //  ===== now draw =====
            // ===========================================================
            g.setColor(C.COLOR_FADE_YELLOW);
            g.drawLine(0, OY, getW() - 20, OY);
            g.setColor(C.COLOR_FADE_YELLOW0);
            g.drawString(mContext.getFontSmall(), "0", getW() - 20, OY, xGraphics.VCENTER);

            int hisW  = (int)(((float)drawW / mCandleCnt) * 2.0f / 3);
            int hisW2 = hisW / 2;

            if (hisW <= 0)
            {
                hisW = 1;
            }
            //g.setColor(0x6000ff00);
            for (i = 0; i < mCandleCnt; i++)
            {
                //g.fillRect(mHistogramXY[2 * i], mHistogramXY[2 * i + 1], hisW, mHistogramH[i]);
                if (mHistogramH[i] < 0)
                {
                    g.setColor(0xff70ee00);
                }
                else
                {
                    g.setColor(0xffc03000);
                }

                //g.drawRect(mHistogramXY[2 * i] - hisW2, mHistogramXY[2 * i + 1], hisW, mHistogramH[i]);
                g.drawRect(mHistogramXY[2 * i], mHistogramXY[2 * i + 1], 1, mHistogramH[i]);
                //g.drawVerticalLine(mHistogramXY[2 * i], mHistogramXY[2 * i + 1] + hisW / 2, mHistogramH[i]);
            }

            g.setColor(C.COLOR_BLUE_LIGHT);
            g.drawLines(mLineMACD, mCandleCnt, 2.0f);

            g.setColor(0xffff0000);
            g.drawLines(mLineSignal9, mCandleCnt, 1.0f);
        }