コード例 #1
0
ファイル: ChartBase.cs プロジェクト: thuyps/vnchart_windows
        protected void drawCandleInfo(xGraphics g)
        {
            if (!mRenderOHLCInfo)
            {
                return;
            }
            if (!mRenderCursor)
            {
                return;
            }

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

            //	candle cursor
            Share share = getShare();

            if (share == null)
            {
                return;
            }
            int selCandleIdx = share.mSelectedCandle;

            if (selCandleIdx >= share.mBeginIdx && selCandleIdx <= share.mEndIdx)
            {
                //		int i = selCandleIdx - share.mBeginIdx;

                //		char sz[128];
                refreshCandleLabels(selCandleIdx);

                int y = mY + 20;
                int x = mX + 4;

                Font f = mFont;
                //f.setColor(0xff00ff00);
                g.setColor(C.COLOR_ORANGE);

                g.drawString(f, mOpen, x, y); y += mFont.Height - 2;
                //g.drawString(f, mClose, x, y); y += mFont.Height - 2;
                g.drawString(f, mHigh, x, y); y += mFont.Height - 2;

                g.setColor(mChangedColor);
                g.drawString(f, mChanged, x, y); y += mFont.Height - 2;
                //g.drawString(f, mLow, x, y); y += mFont.Height - 2;

                g.setColor(C.COLOR_ORANGE);
                g.drawString(f, mVolume, x, y); y += mFont.Height - 2;
                g.drawString(f, mDate, x, y); y   += mFont.Height - 2;
            }
        }
コード例 #2
0
ファイル: AlarmItem.cs プロジェクト: thuyps/vnchart_windows
        int drawThreahold(xGraphics g, int x, int y, bool isUpper)
        {
            int           imgw = mArrowImage.Width / 3;
            int           imgh = mArrowImage.Height;
            Font          f    = mContext.getFontText();
            String        s;
            StringBuilder sb = Utils.getSB();

            if (isUpper)
            {
                g.drawImage(mArrowImage, x, y, imgw, imgh, 0, 0);

                x += 10;
                g.setColor(C.COLOR_WHITE);
                if (mAlarm.upperPrice > 0)
                {
                    sb.AppendFormat("{0:F1}", (float)mAlarm.upperPrice);
                    s = sb.ToString();
                }
                else
                {
                    s = "  -";
                }
                g.drawString(f, s, x, y);

                x += g.getStringWidth(f, s);
            }
            else
            {
                g.drawImage(mArrowImage, x, y, imgw, imgh, imgw, 0);

                x += 10;
                g.setColor(C.COLOR_WHITE);
                if (mAlarm.lowerPrice > 0)
                {
                    sb.AppendFormat("{0:F1}", (float)mAlarm.lowerPrice);
                    s = sb.ToString();
                }
                else
                {
                    s = "  -";
                }
                g.drawString(f, s, x, y);
                x += g.getStringWidth(f, s);
            }

            return(x);
        }
コード例 #3
0
        void drawFiboFan(xGraphics g, stTrendLine t)
        {
            uint color = t.color;       //	blue

            g.setColor(color);

            float[]  percent = { 23.6f, 38.2f, 50.0f, 61.8f };//, 100f};
            String[] txt     = { "23.6", "38.2", "50", "61.8", "100", "161.8" };
            int      y       = 0;
            int      deltaY  = t.y[0] - t.y[1];
            int      dx      = t.x[1] - t.x[0];
            int      dy      = t.y[1] - t.y[0];

            for (int i = 0; i < percent.Length; i++)
            {
                y = t.y[0] - (int)(deltaY * percent[i] / 100);
                int x2  = t.x[1] + 2 * dx;
                int dx2 = x2 - t.x[0];
                dy = y - t.y[0];    //  => y = dy + t.y[0]

                //  dx/dx2 = dy/dy2
                int dy2 = 0;
                if (dx != 0)
                {
                    dy2 = dx2 * dy / dx;
                    y   = t.y[0] + dy2;
                }

                g.drawLineDotHorizontal(t.x[0], t.y[0], x2, y);
                g.drawString(mFont, txt[i], x2 - 30, y);
            }
        }
コード例 #4
0
ファイル: ChartBubble.cs プロジェクト: thuyps/vnchart_windows
        override public void render(xGraphics g)
        {
            g.setColor(C.COLOR_BLACK);
            g.clear();
            //  title
            String title = "";

            if (mChartType == BUBBLE_TRADE_MONEY)
            {
                title = "Đồ thị minh họa luồng tiền (Mã / Giá trị GD / Thay đổi giá)";
            }
            else if (mChartType == BUBBLE_VOLUME_WEIGHT)
            {
                title = "Đồ thị minh họa mức độ ảnh hưởng (Mã / Trọng số / Thay đổi giá)";
            }
            else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC)
            {
                title = "Tốp mã làm tăng thị trường (Mã / Thay đổi index / Thay đổi giá)";
            }
            else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC)
            {
                title = "Tốp mã làm giảm thị trường (Mã / Thay đổi index / Thay đổi giá)";
            }
            Font f = mContext.getFontText();

            g.setColor(C.COLOR_WHITE);
            g.drawString(f, title, 10, 2, xGraphics.TOP | xGraphics.LEFT);

            for (int i = 0; i < mUsedBlocks.size(); i++)
            {
                stBubbleBlock b = (stBubbleBlock)mUsedBlocks.elementAt(i);
                drawBlock(g, b);
            }
        }
コード例 #5
0
ファイル: ChartBase.cs プロジェクト: thuyps/vnchart_windows
        //======================================
        protected void drawPriceLines(xGraphics g)
        {
            if (getShare() == null)
            {
                return;
            }

            for (int i = 0; i < 5; i++)
            {
                if (mPricesY[i] < -2000)    //  bug
                {
                    break;
                }
                g.setColor(C.GREY_LINE_COLOR);
                g.drawLine(0, mPricesY[i], internalW(), mPricesY[i]);

                String sz = (mPrices[i]).ToString("0.0");
                g.setColor(C.COLOR_GRAY_LIGHT);
                g.drawString(mFont, sz, getW() - 8, mPricesY[i], xGraphics.RIGHT | xGraphics.VCENTER);
            }

            int y = getH() - 4;

            g.setColor(C.GREY_LINE_COLOR);
            g.drawLine(0, y, getW(), y);
        }
コード例 #6
0
        void drawMACDButton(xGraphics g)
        {
            Font f = mContext.getFontSmall();
            int  w = 60;
            int  h = f.Height;
            int  x = 2;
            int  y = 2;

            if (mShouldDrawMACD)
            {
                g.setColor(0xc00080ff);
            }
            else
            {
                g.setColor(0xc0ff8000);
            }
            g.fillRect(x, y, w, h);

            g.setColor(C.COLOR_GRAY);
            g.drawRect(x, y, w, h);

            x += w / 2;// (w - g.getStringWidth(f, "MACD")) / 2;
            y += h / 2;

            g.setColor(C.COLOR_WHITE);
            g.drawString(f, "MACD", x, y, xGraphics.HCENTER | xGraphics.VCENTER);
        }
コード例 #7
0
        void drawFiboArc(xGraphics g, stTrendLine t)
        {
            uint color = t.color;// Constants.COLOR_FIBO_DOT_LINE2;	//	blue

            g.setColor(color);

            float[]  percent = { 23.6f, 38.2f, 50.0f, 61.8f, 100f, 161.8f };
            String[] txt     = { "23.6", "38.2", "50", "61.8", "100", "161.8" };
            int      y       = 0;

            double R = (t.x[0] - t.x[1]) * (t.x[0] - t.x[1]) + (t.y[0] - t.y[1]) * (t.y[0] - t.y[1]);

            R = Math.Sqrt(R);

            int r;

            g.setColor(color);

            for (int i = 0; i < percent.Length; i++)
            {
                r = (int)(R * percent[i]) / 100;

                if (i == 4)
                {
                    g.drawArc(t.x[0], t.y[0], r, 0f, 360);
                }
                else
                {
                    g.drawArcDot(t.x[0], t.y[0], r, 0f, 360);
                }

                g.drawString(mFont, txt[i], t.x[0] - r, t.y[0]);
            }
        }
コード例 #8
0
ファイル: ChartBase.cs プロジェクト: thuyps/vnchart_windows
        protected void drawPriceLines(xGraphics g, float[] prices)
        {
            if (getShare() == null)
            {
                return;
            }

            Share share = getShare();
            float hi    = -100000;
            float lo    = 100000;

            for (int i = share.mBeginIdx; i <= share.mEndIdx; i++)
            {
                if (prices[i] > hi)
                {
                    hi = prices[i];
                }
                if (prices[i] < lo)
                {
                    lo = prices[i];
                }
            }
            float distance = hi - lo;

            if (distance <= 0)
            {
                return;
            }
            float rY = (float)getDrawingH() / distance;
            int   mH = getH();
            int   mY = 0;
            //		float rX = (float)getDrawingW()/mChartLineLength;
            //price
            //rY = (float)priceDistance/drawingH;
            float priceStep = distance / 5;

            for (int i = 0; i < 5; i++)
            {
                mPrices[i]  = lo + i * priceStep + priceStep / 2;
                mPricesY[i] = mY + (mH - getMarginY()) - (int)((mPrices[i] - lo) * rY);
            }
            //===================================
            for (int i = 0; i < 5; i++)
            {
                g.setColor(C.GREY_LINE_COLOR);
                g.drawLine(0, mPricesY[i], internalW(), mPricesY[i]);

                String sz = (mPrices[i]).ToString("0.0");
                g.setColor(C.COLOR_GRAY_LIGHT);
                g.drawString(mFont, sz, getW() - 8, mPricesY[i], xGraphics.RIGHT | xGraphics.VCENTER);
            }

            int y = getH() - 4;

            g.setColor(C.GREY_LINE_COLOR);
            g.drawLine(0, y, getW(), y);
        }
コード例 #9
0
        void drawItems(int offset, int itemPerColumn, float x, float y0, float cellW, float cellH, float maxPercent, int numberOfColumns, xGraphics g)
        {
            //====================================
            for (int i = 0; i < itemPerColumn; i++)
            {
                int j = i + offset;
                if (j >= mChanges.size())
                {
                    return;
                }

                int y = (int)(y0 + i * cellH);

                ShareChanges gc = (ShareChanges)mChanges.elementAt(j);
                cellW = (float)((Math.Abs(gc.changedPercent) / maxPercent) * getW() / numberOfColumns);
                //if (gc.changedPercent >= 0)
                {
                    g.setColor(gc.changedPercent > 0?C.COLOR_GREEN_DARK:C.COLOR_RED);
                    g.fillRectF(x, y, cellW, cellH - 2);

                    //  text
                    g.setColor(C.COLOR_WHITE);
                    if (gc.changedPercent > 0)
                    {
                        string s = String.Format("{0} +{1:F2} %", gc.code, gc.changedPercent);
                        g.drawString(mContext.getFontText(), s, (int)x, (int)(y + cellH / 2), xGraphics.VCENTER);
                    }
                    else
                    {
                        string s = String.Format("{0} {1:F2} %", gc.code, gc.changedPercent);
                        g.drawString(mContext.getFontText(), s, (int)x, (int)(y + cellH / 2), xGraphics.VCENTER);
                    }
                    j++;

                    gc.x = (int)x;
                    gc.y = (int)y;
                    gc.w = (int)getW() / numberOfColumns - 10;
                    gc.h = (int)cellH;
                }
            }
            //g.setColor(C.COLOR_GRAY_DARK);
            //g.drawVerticalLine((int)(x + cellW), (int)y0, getH());
        }
コード例 #10
0
        void drawAbc(xGraphics g, stTrendLine t)
        {
            string text = (string)t.data;

            if (text != null)
            {
                g.setColor(t.color);
                g.drawString(mFont, text, t.x[0], t.y[0]);
            }
        }
コード例 #11
0
ファイル: ChartCFM.cs プロジェクト: thuyps/vnchart_windows
        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);
        }
コード例 #12
0
ファイル: AlarmItem.cs プロジェクト: thuyps/vnchart_windows
        void drawQuotePoint(xGraphics g, int x)
        {
            stPriceboardState ps = mContext.mPriceboard.getPriceboard(mAlarm.code);

            //  current price
            float price = ps.getCurrentPrice();
            uint  color = mContext.valToColorF(price, ps.getCe(), ps.getRef(), ps.getFloor());

            if (price == 0)
            {
                price = ps.getRef();
            }

            Font          f  = mContext.getBigFont();
            StringBuilder sb = Utils.getSB();

            //  current price
            sb.AppendFormat("{0:F2}", (float)price);
            int y = 0;

            //l.setFont(f);
            g.setColor(color);
            g.drawString(f, sb.ToString(), x, y);

            y += f.Height;
            //  change
            float change        = price - ps.getRef();
            float changePercent = 0;

            if (ps.getRef() > 0)
            {
                changePercent = (change * 100) / ps.getRef();
            }
            sb.Length = 0;
            sb.AppendFormat("{0:F1} ({1:F2}%)", (float)change, changePercent);

            f = mContext.getFontText();

            g.setColor(color);
            g.drawString(f, sb.ToString(), x, y);
        }
コード例 #13
0
        void drawFiboTime(xGraphics g, stTrendLine t)
        {
            uint color = t.color;       //	blue

            g.setColor(color);

            float[]  percent = { 0, 23.6f, 38.2f, 50.0f, 61.8f, 100f, 161.8f };
            String[] txt     = { "0", "23.6", "38.2", "50", "61.8", "100", "161.8" };

            int toRight = 1;

            if (t.x[0] > t.x[1])
            {
                toRight = -1;
            }
            int x0     = mX + t.x[0];
            int deltaX = Utils.ABS_INT((t.x[1] - t.x[0]));
            int maxX   = mX + getW();

            //	int devidedNum = 1000;
            //	char sz[25];

            for (int i = 0; i < 7; i++)
            {
                int x = (int)(x0 + toRight * (percent[i] * deltaX) / 100);
                if (x > maxX || x < 0)
                {
                    continue;
                }

                g.setColor(color);
                if (i == 5)
                {
                    g.drawLine(x, t.y[0], x, mY + getH() - TOP_Y_FIBO_TIME);
                }
                else
                {
                    g.drawLineDotHorizontal(x, t.y[0], x, mY + getH() - TOP_Y_FIBO_TIME);
                }

                if (i == 0 || i == 3 || i == 5 || i == 6)
                {
                    g.setColor(C.COLOR_WHITE);
                    g.drawString(mFont, txt[i], x, t.y[0], 0);//xGraphics::HCENTER|xGraphics::BOTTOM);
                }
            }
        }
コード例 #14
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);
        }
コード例 #15
0
ファイル: ChartBase.cs プロジェクト: thuyps/vnchart_windows
        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);
        }
コード例 #16
0
        void drawPriceLines(xGraphics g, int y, int h)
        {
            int x = 0;
            int w = getW();

            g.drawHorizontalLine(x, y, w);

            //====================price lines=================================
            //  pricelines
            if (price_distance > 0 && mTrade.mShare != null)
            {
                x = 0 + 1;

                float priceRef = mTrade.mShare.getRefFromPriceboard();
                float step     = (price_distance / 5);

                g.setColor(C.GREY_LINE_COLOR);

                String sz;

                Font fNum = mContext.getFontSmall();

                for (int i = -5; i < 5; i++)
                {
                    float price = priceRef + i * step;
                    int   yy    = priceToY(price, y, h);

                    if (yy < 15 || yy > h - 15)
                    {
                        continue;
                    }

                    if (i == 0)
                    {
                        g.setColor(C.YELLOW_LINE_COLOR);
                    }
                    else
                    {
                        g.setColor(C.GREY_LINE_COLOR);
                    }
                    g.drawHorizontalLine(x, yy, getW() - 4);
                    g.setColor(C.COLOR_GRAY_LIGHT);
                    g.drawString(fNum, String.Format("{0:F2}", price), x, yy, xGraphics.VCENTER | xGraphics.LEFT);
                }
            }
        }
コード例 #17
0
        void drawText(xGraphics g, int x)
        {
            Font f      = mContext.getFontSmall();
            Font fLabel = mContext.getFontText();

            //  ma co phieu
            g.setColor(C.COLOR_WHITE);
            string s = "#" + mTrade.getCode();

            g.drawString(mContext.getFontTextB(), s, x, 1);
            x += g.getStringWidth(mContext.getFontTextB(), s) + 5;
            //	time
            if (mCandleCnt > 0)
            {
                g.setColor(C.COLOR_GRAY_DARK);
                g.fillRect(0, getH() - 12, getW(), 12);
                g.setColor(C.COLOR_WHITE);
                g.drawString(f, mTimeStart, 0 + 1, 0 + getH(), xGraphics.BOTTOM | xGraphics.LEFT);
                g.drawString(f, mTimeEnd, mChartXYs[2 * (mCandleCnt - 1)], 0 + getH() - 12, xGraphics.BOTTOM | xGraphics.LEFT);

                g.setColor(C.COLOR_WHITE);
                s = "KL: " + Utils.formatNumber(mTrade.getVolume(-1));
                g.drawString(f, s, (getW() - Utils.getStringW(s, f)) / 2, getH(), xGraphics.BOTTOM);
            }

            g.setColor(C.GREY_LINE_COLOR);
            g.drawHorizontalLine(x, 0 + getH(), getW());
            //=============cursor & some info========================
            if (mCandleCnt > 0)
            {
                //x = getW() / 2;
                g.setColor(C.COLOR_GRAY_LIGHT);
                g.drawString(fLabel, mCurrentTrade, x, 0 + 1, xGraphics.LEFT);// xGraphics.HCENTER | xGraphics.TOP);
                g.setColor(C.COLOR_FADE_YELLOW0);
                g.drawVerticalLine(mChartXYs[2 * mCurrentTradeSel], 12, getH() - 26);
                //g.drawPoint(mChartXYs[2 * mCurrentTradeSel] - 2, mChartXYs[2 * mCurrentTradeSel + 1] - 4, 4);

                if (mChangedValue > 0)
                {
                    g.setColor(C.COLOR_GREEN);
                }
                else if (mChangedValue == 0)
                {
                    g.setColor(C.COLOR_YELLOW);
                }
                else
                {
                    g.setColor(C.COLOR_RED);
                }
                g.drawString(fLabel, mChanged, mChartXYs[2 * mCurrentTradeSel], 26);
            }
            //=====================================================
        }
コード例 #18
0
ファイル: ChartBase.cs プロジェクト: thuyps/vnchart_windows
        protected void renderCursor(xGraphics g)
        {
            if (!mShouldDrawCursor)
            {
                return;
            }
            Share share = getShare();

            if (share == null)
            {
                return;
            }

            int sel = share.getCursor();
            int x   = candleToX(sel);

            g.setColor(C.COLOR_GRAY);
            g.drawLine(x, 0, x, getH());

            //  mouse title
            g.setColor(C.COLOR_FADE_YELLOW);
            g.drawLineDotHorizontal(0, mLastY, getW());

            if (mMouseTitle != null && mLastY != 0 & mLastY != 0)
            {
                int y = mLastY;
                x = mLastX;
                if (y < 12)
                {
                    y  = mLastY + 12;
                    x += 6; //  stay away from the mouse
                }
                g.setColor(0xa0000000);
                int sw = Utils.getStringW(mMouseTitle, mContext.getFontSmall());
                g.fillRect(x, y - 12, sw, mContext.getFontSmall().Height);

                g.setColor(C.COLOR_ORANGE);
                g.drawString(mContext.getFontSmall(), mMouseTitle, x, y - 12);
            }

            if (mShouldDrawTitle)
            {
                renderTitles(g, 2, 0);
            }
        }
コード例 #19
0
        override public void render(xGraphics g)
        {
            g.setColor(C.COLOR_BLACK);
            g.clear();

            if (isProcessing)
            {
                g.setColor(C.COLOR_ORANGE);
                g.drawStringInRect(mContext.getFontSmallB(), "Đang xử lý", 0, 0, getW(), getH(), xGraphics.HCENTER | xGraphics.VCENTER);
                return;
            }
            //  title
            String title  = "";
            String prefix = mMarketID == 1 ? "[VNX] " : "[HNX] ";

            if (mChartType == BUBBLE_TRADE_MONEY)
            {
                title = prefix + "Luồng tiền (Mã; Thay đổi giá; Giá trị GD)";
            }
            else if (mChartType == BUBBLE_VOLUME_WEIGHT)
            {
                title = prefix + "Mức độ ảnh hưởng (Mã; Thay đổi giá; Trọng số)";
            }
            else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC)
            {
                title = prefix + "Tăng Index (Mã; Thay đổi giá; Thay đổi điểm)";
            }
            else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC)
            {
                title = prefix + "Giảm Index (Mã; Thay đổi giá; Thay đổi điểm)";
            }
            Font f = mContext.getFontText();

            g.setColor(C.COLOR_WHITE);
            g.drawString(f, title, 10, 2, xGraphics.TOP | xGraphics.LEFT);

            for (int i = 0; i < mUsedBlocks.size(); i++)
            {
                stStatisticsBlock b = (stStatisticsBlock)mUsedBlocks.elementAt(i);
                if (b.w > 0)
                {
                    drawBlock(g, b);
                }
            }
        }
コード例 #20
0
ファイル: ChartBase.cs プロジェクト: thuyps/vnchart_windows
        virtual public int renderTitles(xGraphics g, int x, int y)
        {
            xVector v = getTitles();

            if (v != null)
            {
                for (int i = 0; i < v.size(); i++)
                {
                    stTitle t = (stTitle)v.elementAt(i);
                    g.setColor(t.color);
                    g.drawString(mFont, t.title, x, y);

                    x += g.getStringWidth(mFont, t.title) + 20;
                }
            }

            return(x);
        }
コード例 #21
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);
        }
コード例 #22
0
        public override void render(xGraphics g)
        {
            if (isFocus())
            {
                g.setColor(0xff306AC5);
            }
            else
            {
                g.setColor(C.COLOR_BLACK);
            }
            g.clear();
            g.setColor(0xffffffff);
            g.drawLine(0, getH() - 1, getW(), getH() - 1);
            stPriceboardStateIndex pi = mContext.mPriceboard.getPriceboardIndexOfMarket(mMarketID);

            if (pi == null /* || pi.current_point == 0*/)
            {
                return;
            }

            //===========================================
            //  VNIndex 375.3 (-1.86, -0.49%)   KL: 37,716,548 GT: 560.9 ty     up:84 no:53 down:169
            //===========================================
            int  x = 0;
            int  y = 0;
            uint color;

            g.setColor(C.COLOR_WHITE);
            g.drawString(mFont, pi.code, x, y);

            x = 75;

            if (pi.changed_point > 0)
            {
                color = C.COLOR_GREEN;
            }
            else if (pi.changed_point < 0)
            {
                color = C.COLOR_RED;
            }
            else
            {
                color = C.COLOR_YELLOW;
            }
            g.setColor(color);

            String s;

            s = String.Format("{0:F2}", pi.current_point);
            //  point
            g.drawString(mFont, s, x, y);
            x = 130;
            //  change
            String        s1             = String.Format("{0:F2}", pi.changed_point);
            float         changedPercent = (pi.changed_point * 100) / pi.current_point;
            String        s2             = String.Format("{0:F2}%", changedPercent);
            StringBuilder sb             = Utils.sb;

            sb.Length = 0;
            sb.AppendFormat("({0}, {1})", s1, s2);
            s = sb.ToString();
            g.drawString(mFont, s, x, y);
            x = 220;
            //  KL
            g.setColor(C.COLOR_WHITE);
            double t = pi.total_volume;

            t /= 1000000;
            //s =
            s = Utils.formatNumber((float)t, 2);
            //Utils.formatNumber(0, 1);
            sb.Length = 0;
            sb.AppendFormat("KLGD: {0} tr", s);
            g.drawString(mFont, sb.ToString(), x, y);

            x = 330;
            //  GT
            s         = Utils.formatDecimalNumber(pi.totalGTGD, 1000, 1);
            sb.Length = 0;
            sb.AppendFormat("GTGD: {0} tỷ", s);
            g.drawString(mFont, sb.ToString(), x, y);

            x = 440;

            //  up/none/down
            int frmW = mArrows.Width / 3;
            int frmH = mArrows.Height;

            g.drawImage(mArrows, x, y, frmW, frmH, 0, 0);
            x += frmW + 2;
            g.setColor(C.COLOR_GREEN);
            g.drawString(mFont, "" + pi.inc_cnt, x, y);
            x += 40;
            //  none
            g.drawImage(mArrows, x, y, frmW, frmH, 2 * frmW, 0);
            x += frmW + 2;
            g.setColor(C.COLOR_YELLOW);
            g.drawString(mFont, "" + pi.ref_num, x, y);
            x += 40;
            //  down
            g.drawImage(mArrows, x, y, frmW, frmH, frmW, 0);
            x += frmW + 2;
            g.setColor(C.COLOR_RED);
            g.drawString(mFont, "" + pi.dec_cnt, x, y);
            //  date

            x += 50;

            //  cung-cau
            g.setColor(C.COLOR_WHITE);

            double[] tt = { 0, 0 };
            calcBuySellRemains(pi.marketID, tt);
            //  mua
            t = tt[0] / 1000000;
            s = Utils.formatNumber((float)t, 1);
            //  ban
            t         = tt[1] / 1000000;
            s1        = Utils.formatNumber((float)t, 1);
            sb.Length = 0;
            sb.AppendFormat("Dư M/B={0} / {1}", s, s1);
            g.drawString(mFont, sb.ToString(), x, y);

            x += 150;

            g.setColor(C.COLOR_WHITE);
            g.drawString(mFont, pi.mDate, x, y);
        }
コード例 #23
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);
        }
コード例 #24
0
ファイル: ChartADX.cs プロジェクト: thuyps/vnchart_windows
        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);
        }
コード例 #25
0
ファイル: AlarmItem.cs プロジェクト: thuyps/vnchart_windows
        public override void render(xGraphics g)
        {
            g.setColor(C.COLOR_BLACK);
            g.clear();

            stPriceboardState ps = mContext.mPriceboard.getPriceboard(mAlarm.code);

            if (ps == null)
            {
                return;
            }

            Font f = mContext.getBigFont();
            int  x = 0;
            int  y = 0;

            //  code
            x = 4;
            y = (getH() - f.Height) / 2 - 4;
            g.setColor(C.COLOR_WHITE);
            g.drawString(f, mAlarm.code, x, y - 4);

            x += 120;
            //  gia hien tai
            drawQuotePoint(g, x);

            x += 120;

            //  upper alarm
            int ch = getH() / 2 - 5;

            f = mContext.getFontText();
            y = (ch - f.Height) / 2;
            int x0 = drawThreahold(g, x, y, true);   //  upper

            y = ch + (ch - f.Height) / 2;
            int x1 = drawThreahold(g, x, y, false);   //  lower

            x = x0 > x1? x0 + 2:x1 + 2;
            //=========================================
            int alarm = mAlarm.hasAlarm();

            if (alarm != 0)
            {
                String s;
                if (alarm == 1)
                {
                    s = "Giá đã vượt lên trên " + Utils.formatNumber(mAlarm.upperPrice);
                    g.setColor(C.COLOR_GREEN);
                    y = (ch - mAlarmImage.Height) / 2;
                }
                else
                {
                    s = "Giá đã xuống thấp hơn " + Utils.formatNumber(mAlarm.lowerPrice);
                    g.setColor(C.COLOR_RED);
                    y = ch + (ch - mAlarmImage.Height) / 2;
                }
                if (mShowingAlarm)
                {
                    g.drawImage(mAlarmImage, x, y);
                }
                g.drawString(f, s, x + mAlarmImage.Width + 10, y + 2);
            }

            if (mAlarm.comment != null && mAlarm.comment.Length > 0)
            {
                y = getH() - f.Height - 1;
                g.setColor(C.COLOR_YELLOW);
                g.drawString(mContext.getFontTextItalic(), "(" + mAlarm.comment + ")", 8, y);
            }

            //=======================
            g.setColor(C.COLOR_WHITE);
            g.drawHorizontalLine(0, getH() - 1, getW());
        }
コード例 #26
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);
        }
コード例 #27
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);
            }
        }
コード例 #28
0
ファイル: IndexCandle.cs プロジェクト: thuyps/vnchart_windows
        void drawCandle(xGraphics g, int x, int y0, int w, int h)
        {
            Share share = mShare;

            int  y = 0;
            Font f = mContext.getFontSmall();

            uint color;

            stPriceboardState ps = mContext.mPriceboard.getPriceboard(share.getID());

            if (ps == null)
            {
                return;
            }

            TradeHistory trade = mContext.getTradeHistory(share.getID());
            float        price = ps.getCurrentPrice();
            float        open  = price;//ps.getRef(); //  should be open - testing

            if (trade != null && trade.getTransactionCount() > 0)
            {
                open = trade.getPrice(0);
            }
            else
            {
                open = mContext.mPriceboard.getOpen(mShare.mID);
            }

            if (open != 0 && mContext.mPriceboard.getOpen(mShare.mID) == 0 && !share.isIndex())
            {
                mContext.mPriceboard.setOpen(mShare.mID, (int)open);
            }

            float hi       = ps.getMax();
            float lo       = ps.getMin();
            float priceLen = hi - lo;

            float reference = ps.getRef();
            float min       = ps.getFloor() - (float)reference / 30;
            float max       = ps.getCe() + (float)reference / 30;

            if (share.isIndex())
            {
                price     = trade.mClose / 10.0f;
                open      = trade.mOpen / 10.0f;
                reference = trade.mPriceRef / 10.0f;
                hi        = trade.mHighest / 10.0f;
                lo        = trade.mLowest / 10.0f;
                min       = reference - reference / 40;
                max       = reference + reference / 40;

                if (min > lo)
                {
                    min = lo;
                }
                if (max < hi)
                {
                    max = hi;
                }

                priceLen = (int)(hi - lo);
            }

            if (price == 0)
            {
                return;
            }

            //if (min > ps.getMin() && ps.getMin() > 0) min = ps.getMin();
            //if (max < ps.getMax()) max = ps.getMax();

            float totalPrice = (max - min);  //(10%);

            if (totalPrice < priceLen)
            {
                totalPrice = priceLen;
            }

            if (totalPrice == 0)
            {
                return;
            }

            float ry = (float)(h) / totalPrice;

            int           totalH = (int)(ry * totalPrice);
            int           bodyW  = w / 3;
            StringBuilder sb     = Utils.getSB();

            //================frame=============================
            //  line ref
            g.setColor(0x30ffff00);
            y = (int)(y0 + totalH - (reference - min) * ry);
            g.drawLineDotHorizontal(1, y, getW() - 2, y);
            g.setColor(0xa0ffff00);

/*
 *          if (mDrawRefLabel)
 *          {
 *              sb.AppendFormat("{0:F1}", (float)reference / 10);
 *              g.drawString(f, sb.ToString(), 1, y - f.Height / 2, 0);
 *          }
 */
            //  CE line
            if (!share.isIndex())
            {
                g.setColor(0x30ff00ff);
                y = (int)(y0 + totalH - (ps.getCe() - min) * ry);
                g.drawLineDotHorizontal(1, y, getW() - 2, y);
                g.setColor(0xa0ff00ff);
                sb.Length = 0;
                sb.AppendFormat("{0:F1}", (float)(ps.getCe() / 10));

                if (mDrawRefLabel)
                {
                    g.drawString(f, sb.ToString(), 1, y, 0);
                }

                //  FLOOR line
                g.setColor(0x3000FFFF);
                y = (int)(y0 + totalH - (ps.getFloor() - min) * ry);
                g.drawLineDotHorizontal(1, y, getW() - 2, y);
                g.setColor(0xa000FFFF);
                sb.Length = 0;
                sb.AppendFormat("{0:F1}", (float)(ps.getFloor() / 10));
                if (mDrawRefLabel)
                {
                    g.drawString(f, sb.ToString(), 1, y - f.Height, 0);
                }
            }
            //===================================================
            color = price < open? C.COLOR_RED:C.COLOR_GREEN;
            if (price == open)
            {
                color = C.COLOR_WHITE;
            }
            if (price == 0)
            {
                return;
            }
            //  draw shadow
            g.setColor(C.COLOR_WHITE);
            x = getW() / 2;

            if (share.isIndex() && hi > 0 && lo > 0)
            {
                int minY = (int)(y0 + totalH - (lo - min) * ry);
                int maxY = (int)(y0 + totalH - (hi - min) * ry);

                g.drawLine(x, maxY, x, minY);
            }
            int centerX = x + bodyW / 2;
            //  candle's body
            int oY = (int)(y0 + totalH - (open - min) * ry);
            int cY = (int)(y0 + totalH - (price - min) * ry);

            y = oY < cY?oY:cY;
            int bodyH = Utils.ABS_INT(cY - oY);

            if (bodyH < 2)
            {
                bodyH = 2;
            }
            g.setColor(color);
            g.fillRect(x - bodyW / 2, y, bodyW, bodyH);

            /*
             * if (lo > 0 && lo != open && lo != price)
             * {
             *  y = (int)(y0 + totalH - (lo - min)*ry);
             *  g.setColor(C.COLOR_WHITE);
             *  sb.Length = 0;
             *  sb.AppendFormat("{0:F1}", (float)lo/10);
             *  g.drawString(f, sb.ToString(), centerX - 44, y + 1, 0);
             * }
             * if (hi > 0 && hi != open && hi != price)
             * {
             *  y = (int)(y0 + totalH - (hi - min)*ry);
             *  g.setColor(C.COLOR_WHITE);
             *  sb.Length = 0;
             *  sb.AppendFormat("{0:F1}", (float)hi/10);
             *  g.drawString(f, sb.ToString(), centerX - 44, y - f.Height, 0);
             * }
             * //  2 lines
             * g.setColor(C.COLOR_WHITE);
             * sb.Length = 0;
             * sb.AppendFormat("{0:F1}", (float)open/10);
             *
             * //  open
             * if (oY < cY)
             *  y = oY - f.Height;
             * else
             *  y = oY + 1;
             * if (y < 0) y = 0;
             * if (y + f.Height > getH())
             *  y = getH() - f.Height;
             * g.drawString(f, sb.ToString(), x + bodyW / 2, y, 0);
             * //  price
             * sb.Length = 0;
             * sb.AppendFormat("{0:F1}", (float)price/10);
             * if (cY < oY)
             *  y = cY - f.Height;
             * else
             *  y = cY + 1;
             * if (y < 0) y = 0;
             * if (y + f.Height > getH())
             *  y = getH() - f.Height;
             * g.drawString(f, sb.ToString(), x + bodyW / 2, y, 0);
             */
        }
コード例 #29
0
        override public void render(xGraphics g)
        {
            //=========================
            if (viewState == VIEWSTATE_1_NHOMNGANH && chartG != null)
            {
                chartG.render(g);
                return;
            }

            g.setColor(C.COLOR_BLACK);
            g.clear();

            if (isProcessing)
            {
                g.setColor(C.COLOR_ORANGE);
                g.drawStringInRect(mContext.getFontSmallB(), "Đang xử lý", 0, 0, getW(), getH(), xGraphics.HCENTER | xGraphics.VCENTER);
                return;
            }

            //  title
            //      [Hom nay] [1 Tuan] [1 Thang] [3 thang] [1 nam]
            //          Tang          |          Giam          |
            //  VN30: +15%; GTDG: 30.1ti    .Chart
            //
            if (mChanges.size() == 0)
            {
                calcChanged(mPeriod);
            }
            if (mChanges.size() == 0)
            {
                return;
            }


            float x, y;
            int   buttonW = 80;
            int   buttonH = 26;

            int gap = 4;

            x = (getW() - 6 * (buttonW + gap)) / 2;

            //  button
            y = 2;
            mButtonPositions.removeAllElements();
            mPeriods.removeAllElements();
            string[] buttons = { "1 Ngày", "1 Tuần", "1 Tháng", "3 Tháng", "6 Tháng", "1 Năm" };
            int[]    periods = { 1, 5, 22, 67, 130, 260 };
            for (int i = 0; i < buttons.Length; i++)
            {
                string s = buttons[i];
                g.setColor(C.COLOR_GRAY_LIGHT);
                g.drawRect((int)x, 2, buttonW, buttonH);
                g.setColor(mPeriod == periods[i]?C.COLOR_ORANGE:C.COLOR_WHITE);
                g.drawStringInRect(mContext.getFontSmallB(), s, (int)x, (int)y, buttonW, buttonH, xGraphics.HCENTER | xGraphics.VCENTER);

                Rectangle rc = new Rectangle((int)x, 2, buttonW, buttonH);
                mButtonPositions.addElement(rc);
                mPeriods.addElement(periods[i]);

                x += buttonW + gap;
            }

            g.setColor(C.COLOR_GRAY_DARK);
            g.drawHorizontalLine(0, buttonH + 4, getW());

            int    columnH    = ItemH;
            double maxPercent = 0;

            for (int i = 0; i < mChanges.size(); i++)
            {
                GroupChanges gc = (GroupChanges)mChanges.elementAt(i);
                if (Math.Abs(gc.changedPercent) > maxPercent)
                {
                    maxPercent = Math.Abs(gc.changedPercent);
                }
            }
            //--------------------
            int buttonY = 30;
            int drawH   = getH() - buttonY;

            ItemH = getItemH(getH() - 40, mChanges.size());

            float cellW = getW() / 2;
            float cellH = ItemH;

            maxPercent *= 1.15;
            //  Left side
            int j = 0;

            y = buttonY + 4;

            int itemPerColumn = mChanges.size() / 2;

            for (int i = 0; i < itemPerColumn; i++)
            {
                GroupChanges gc = (GroupChanges)mChanges.elementAt(i);
                x = 2;
                //if (gc.changedPercent >= 0)
                {
                    y     = buttonY + 4 + j * cellH;
                    cellW = (float)((Math.Abs(gc.changedPercent) / maxPercent) * getW() / 2);
                    g.setColor(gc.changedPercent > 0?C.COLOR_GREEN_DARK:C.COLOR_RED);
                    g.fillRectF(x, y, cellW, cellH - 2);

                    //  text
                    g.setColor(C.COLOR_WHITE);
                    if (gc.changedPercent >= 0)
                    {
                        string s = String.Format("{0} +{1:F2} %", gc.code, gc.changedPercent);
                        g.drawString(mContext.getFontText(), s, (int)x, (int)(y + cellH / 2), xGraphics.VCENTER);
                    }
                    else
                    {
                        string s = String.Format("{0} {1:F2} %", gc.code, gc.changedPercent);
                        g.drawString(mContext.getFontText(), s, (int)x, (int)(y + cellH / 2), xGraphics.VCENTER);
                    }
                    j++;

                    gc.x = (int)x;
                    gc.y = (int)y;
                    gc.w = (int)getW() / 2 - 10;
                    gc.h = (int)cellH;
                }
            }
            g.setColor(C.COLOR_GRAY_DARK);
            g.drawVerticalLine(getW() / 2, buttonY, getH());
            //  Right side
            j = 0;
            for (int i = itemPerColumn; i < mChanges.size(); i++)
            {
                GroupChanges gc = (GroupChanges)mChanges.elementAt(i);
                x = getW() / 2 + 2;
                //if (gc.changedPercent < 0)
                {
                    y     = buttonY + 4 + j * cellH;
                    cellW = (float)((Math.Abs(gc.changedPercent) / maxPercent) * getW() / 2);
                    g.setColor(gc.changedPercent > 0 ? C.COLOR_GREEN_DARK : C.COLOR_RED);
                    g.fillRectF(x, y, cellW, cellH - 2);

                    //  text
                    g.setColor(C.COLOR_WHITE);
                    if (gc.changedPercent >= 0)
                    {
                        string s = String.Format("{0}: +{1:F2} %", gc.code, gc.changedPercent);
                        g.drawString(mContext.getFontText(), s, (int)x, (int)(y + cellH / 2), xGraphics.VCENTER);
                    }
                    else
                    {
                        string s = String.Format("{0}: {1:F2} %", gc.code, gc.changedPercent);
                        g.drawString(mContext.getFontText(), s, (int)x, (int)(y + cellH / 2), xGraphics.VCENTER);
                    }
                    j++;

                    gc.x = (int)x;
                    gc.y = (int)y;
                    gc.w = (int)getW() / 2 - 10;
                    gc.h = (int)cellH;
                }
            }
        }
コード例 #30
0
ファイル: ChartMCDX.cs プロジェクト: thuyps/vnchart_windows
        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);
        }