//====================================== 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); }
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); }
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); }
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); } } }
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); }
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); } }
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); }
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); }
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); */ }
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); }
public override void render(xGraphics g) { if (getID() < 0) { return; } int x = 0; int y = 2; int h = getH(); if (mCells.size() == 0) { return; } if (mIsSelected && getID() > 0) { g.setColor(C.COLOR_BUTTON_SEL); g.fillRect(0, 0, getW(), getH()); } int i; x = 0; for (i = 0; i < mCells.size(); i++) { stCell c = (stCell)mCells.elementAt(i); uint color = c.bgColor; int w = c.w; x = c.x; if (color != COLOR_NONE) { g.setColor(color); g.fillRect(x, 0, w, h); } } //---------text // printf("\n=========================================="); for (i = 0; i < mCells.size(); i++) { stCell c = (stCell)mCells.elementAt(i); if (i == mCandleColumeIdx && getID() != 0) { renderCandle(g, c); continue; } if (c.text2 == null) { g.setColor(c.textColor); if (c.text != null) { g.drawStringInRect(c.f, c.text, c.x, 0, c.w, h, xGraphics.HCENTER | xGraphics.VCENTER); } } else { g.setColor(c.textColor); g.drawStringInRect(c.f, c.text, c.x, (int)(h / 2 - c.f.GetHeight()) - 0, c.w, h / 2, xGraphics.HCENTER | xGraphics.VCENTER); g.setColor(c.textColor2); g.drawStringInRect(c.f, c.text2, c.x, h / 2 + 2, c.w, (int)(c.f.GetHeight()), xGraphics.HCENTER | xGraphics.VCENTER); } //Utils.trace("here 5:" + c.text + " x=" + c.x + " w=" + c.w + " h=" + h); } // grid g.setColor(0xff808080); for (i = 1; i < mCells.size(); i++) { stCell c = (stCell)mCells.elementAt(i); x = c.x; g.drawLine(x, y, x, y + h); } g.drawHorizontalLine(0, 0, getW()); // snapshot and volume String code = getCode(); if (code != null) { // volume stPriceboardState item = Context.getInstance().mPriceboard.getPriceboard(code); if (item != null) { renderSnapshot(3, item, g); } } }
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 = mContext.mPriceboard.getOpen(ps.getID()); 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(); // check hi/lo valid if ((hi == 0 || lo == 0)) { float[] hl = new float[2]; if (trade.getHiLo(hl)) { if (hi == 0) { hi = hl[0]; } if (lo == 0) { lo = hl[1]; } } } if (hi == 0) { hi = open > price ? open : price; } if (lo == 0) { lo = open < price ? open : price; } if (lo == 0) { lo = hi; } //--------------------------------------------- float priceLen = hi - lo; float reference = ps.getRef(); float min, max; if (share.isIndex()) { stPriceboardStateIndex pi = mContext.mPriceboard.getPriceboardIndexOfMarket(mShare.getMarketID()); price = pi.current_point; min = lo - price / 40; max = hi + price / 40; } else { min = ps.getFloor() - reference / 30; max = ps.getCe() + reference / 30; } 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:F2}", reference); 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:F2}", ps.getCe()); 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:F2}", ps.getFloor()); 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 (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; // 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_YELLOW); sb.Length = 0; sb.AppendFormat("{0:F2}", lo); g.drawString(f, sb.ToString(), centerX - 10, y + 1, 0); } if (hi > 0 && hi != open && hi != price) { y = (int)(y0 + totalH - (hi - min) * ry); g.setColor(C.COLOR_YELLOW); sb.Length = 0; sb.AppendFormat("{0:F2}", hi); g.drawString(f, sb.ToString(), centerX - 10, y - f.Height, 0); } // 2 lines g.setColor(C.COLOR_WHITE); sb.Length = 0; sb.AppendFormat("{0:F2}", open); // 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:F2}", price); 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); }
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); }
protected void drawDateSeparator(xGraphics g) { if (!mShouldDrawDateSeparator) { return; } if (getShare() == null) { return; } Share share = getShare(); if (share.isRealtime()) { return; } int y = getH() - 4; //----------draw vertical separators int range = share.getCursorScope(); int[] scopes = { Share.SCOPE_1WEEKS, Share.SCOPE_1MONTH, Share.SCOPE_3MONTHS, Share.SCOPE_6MONTHS, Share.SCOPE_1YEAR, Share.SCOPE_2YEAR, Share.SCOPE_ALL, -1 }; int scope = 1; int i = 1; while (scopes[i] != -1) { if (scopes[i] >= range) { scope = scopes[i]; break; } i++; } if (range > Share.SCOPE_2YEAR) { scope = Share.SCOPE_ALL; } //----------------------------------------- int lastSeperator = -1; int flag = 0; int jump = 0; StringBuilder sb = new StringBuilder(100); String sz; for (i = share.mBeginIdx; i < share.mEndIdx; i++) { if (scope == Share.SCOPE_1WEEKS) { } else if (scope == Share.SCOPE_1MONTH) { i = seekToFirstDayOfWeek(share, i); jump = 2; } else if (scope == Share.SCOPE_3MONTHS) { i = seekToFirstDayOfWeek(share, i); jump = 2; } else if (scope == Share.SCOPE_6MONTHS) { i = seekToFirstDayOfMonth(share, i); jump = 10; } else if (scope == Share.SCOPE_1YEAR) { i = seekToFirstDayOfMonth(share, i); jump = 10; } else if (scope == Share.SCOPE_2YEAR) { i = seekToFirstDayOfMonth(share, i); jump = 16; flag++; if (flag == 3) { flag = 0; } } else if (scope == Share.SCOPE_ALL) { i = seekToFirstDayOfQ(share, i); jump = 100; // about 6 months //flag++; //if (flag == 3) ///flag = 0; } if (i == -1 || i >= share.mEndIdx) { break; } if (flag != 0) { continue; } lastSeperator = share.getDate(i); int m = ((lastSeperator >> 8) & 0xff) - 1; int d = (lastSeperator & 0xff); int year = (lastSeperator >> 16) & 0xffff; year = year % 100; sb.Length = 0; if (scope == Share.SCOPE_ALL) { sb.AppendFormat("{0:D2}/{1:D2}", (m + 1), year); } else { sb.AppendFormat("{0:D2}/{1:D2}", d, m + 1); } sz = sb.ToString(); int x = candleToX(i); //g.setColor(C.GREY_LINE_COLOR); g.setColor(0x70454545); g.drawLine(x, y - 30, x, y); //g.drawLine(x, 0, x, y); g.setColor(C.COLOR_GRAY_LIGHT); Font fs = mContext.getFontSmaller(); g.drawString(fs, sz, x, y - fs.Height, xGraphics.LEFT); //-------------------- i += jump; } }
override public void render(xGraphics g) { if (getID() < 0) { return; } int x = 0; int y = 2; int h = getH(); if (mCells.size() == 0) { return; } if (mIsSelected && getID() > 0) { g.setColor(C.COLOR_BUTTON_SEL); g.fillRect(0, 0, getW(), getH()); } int i; x = 0; for (i = 0; i < mCells.size(); i++) { stCell c = (stCell)mCells.elementAt(i); uint color = c.bgColor; int w = c.w; x = c.x; if (color != COLOR_NONE) { g.setColor(color); g.fillRect(x, 0, w, h); } } //---------text // printf("\n=========================================="); for (i = 0; i < mCells.size(); i++) { stCell c = (stCell)mCells.elementAt(i); if (i == mCandleColumeIdx && getID() != 0) { renderCandle(g, c); continue; } if (c.text2 == null) { g.setColor(c.textColor); if (c.text != null) { g.drawStringInRect(c.f, c.text, c.x, 0, c.w, h, xGraphics.HCENTER | xGraphics.VCENTER); } } else if (getH() < 36) { g.setColor(c.textColor); g.drawStringInRect(c.f, c.text, c.x, (int)(h / 2 - c.f.GetHeight()) + 3, c.w, h / 2, xGraphics.HCENTER | xGraphics.VCENTER); g.setColor(c.textColor2); g.drawStringInRect(c.f, c.text2, c.x, h / 2 + 1, c.w, (int)(c.f.GetHeight()), xGraphics.HCENTER | xGraphics.VCENTER); } else { g.setColor(c.textColor); g.drawStringInRect(c.f, c.text, c.x, (int)(h / 2 - c.f.GetHeight()) - 0, c.w, h / 2, xGraphics.HCENTER | xGraphics.VCENTER); g.setColor(c.textColor2); g.drawStringInRect(c.f, c.text2, c.x, h / 2 + 2, c.w, (int)(c.f.GetHeight()), xGraphics.HCENTER | xGraphics.VCENTER); } //Utils.trace("here 5:" + c.text + " x=" + c.x + " w=" + c.w + " h=" + h); } // grid g.setColor(0xff808080); for (i = 1; i < mCells.size(); i++) { stCell c = (stCell)mCells.elementAt(i); x = c.x; g.drawLine(x, y, x, y + h); } g.drawHorizontalLine(0, 0, getW()); /* * // history chart button * if (getID() > 0) * { * g.setColor(C.COLOR_ORANGE); * int tmp = 6; * y = getH() / 2; * x = getW() - tmp - 4; * g.drawLine(x, y - tmp, x + tmp, y); * g.drawLine(x, y + tmp, x + tmp, y); * } */ // render snapshot if (mVolumeColumn >= 0) { stPriceboardState item = getPriceboard(); renderSnapshot(11, item, g); } }
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); }
public void drawFiboProjection(xGraphics g, stTrendLine t) { uint color = t.color;// Constants.COLOR_FIBO_DOT_LINE2; // blue g.setColor(color); float[] percent = { 0f, 23.6f, 38.2f, 50.0f, 61.8f, 100f, 161.8f }; String[] txt = { "0", "23.6", "38.2", "50.0", "61.8", "100", "161.8" }; int minX = t.x[0] < t.x[1] ? t.x[0] : t.x[1]; minX = minX < t.x[2] ? minX : t.x[2]; int maxX = t.x[0] > t.x[1] ? t.x[0] : t.x[1] + 30; maxX = mX + getW() - 35; int maxY = mY + getH() - 20; int deltaY = t.y[1] - t.y[0]; if (deltaY < 0) { deltaY = -deltaY; } int up = 1; int y0 = t.y[2]; if (t.x[0] < t.x[1] && t.y[0] < t.y[1]) { up = 1; } if (t.x[0] < t.x[1] && t.y[0] > t.y[1]) { up = -1; } if (t.x[0] > t.x[1] && t.y[0] > t.y[1]) { up = 1; } if (t.x[0] > t.x[1] && t.y[0] < t.y[1]) { up = -1; } String s; for (int i = 0; i < 7; i++) { int y = (int)(y0 + up * (percent[i] * deltaY) / 100); if (y > maxY || y < 0) { continue; } g.setColor(color); if (i == 5) { g.drawLine(minX - 30, y, maxX + 30, y); } else { g.drawLineDotHorizontal(minX - 30, y, maxX + 30, y); } //===================== if (i == 0 || i == 3 || i == 5) { s = Utils.formatDecimalNumber((int)mChart.yToPrice(y), 10, 1); g.setColor(C.COLOR_WHITE); g.drawString(mFont, s, maxX, y, xGraphics.VCENTER | xGraphics.TOP); g.drawString(mFont, txt[i], minX - 30, y, xGraphics.VCENTER | xGraphics.TOP); } } }
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); }
public override void render(xGraphics g) { g.setColor(C.COLOR_BLACK); g.clear(); g.setColor(0xffffffff); g.drawLine(0, 0, 0, getH()); 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 lineH = 20; int x0 = 4; int x = x0; int y = 0; uint color; g.setColor(C.COLOR_WHITE); Font fTitle = mContext.getFontTextItalic(); // date x = x0; g.setColor(C.COLOR_WHITE); g.drawString(fTitle, pi.mDate, x, y); y += lineH; //============================== // VNINDEX g.drawString(mFont, pi.code, x, y); //======point 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 x += g.getStringWidth(mFont, pi.code) + 10; g.drawString(mFont, s, x, y); // change g.setColor(C.COLOR_WHITE); y += lineH + 10; g.drawString(fTitle, "Thay đổi: ", x0, y); x = x0 + g.getStringWidth(fTitle, "Thay đổi: ") + 6; g.setColor(color); // 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 = x0; y += lineH + 10; // 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 = x0; y += lineH; // 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 = x0; y += lineH; // 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ư mua/bán (tr): {0} / {1}", s, s1); g.drawString(mFont, sb.ToString(), x, y); x = x0; y += lineH + 10; g.setColor(C.COLOR_WHITE); g.drawString(fTitle, "Số mã tăng/giảm:", x, y); y += lineH; // 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.floor_cnt, 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); //===========cao: x = x0; g.setColor(C.COLOR_YELLOW); TradeHistory trade = mContext.getTradeHistory(pi.id); // referent s = String.Format("{0:F2}", pi.reference); y += lineH + 10; s = "Tham chiếu: " + s; //fTitle = mContext.getFon g.drawString(mFont, s, x, y); // cao s = String.Format("{0:F2}", trade.mHighest); y += lineH; s = "Cao nhất: " + s; g.drawString(mFont, s, x, y); // thap s = String.Format("{0:F2}", trade.mLowest); y += lineH; s = "Thấp nhất: " + s; g.drawString(mFont, s, x, y); }
//====================================== public void render(xGraphics g) { if (!mShow) { return; } Share share = getShare(3); if (share == null) { return; } int b = share.mBeginIdx; int e = share.mEndIdx; int selSquareSide = 0; uint selSquareColor = 0xff00ff00; for (int i = 0; i < mTrends.size(); i++) { stTrendLine t = (stTrendLine)mTrends.elementAt(i); g.setColor(C.COLOR_ORANGE); // grey if (t.type != DRAW_TREND) { g.setColor(C.COLOR_FIBO_DOT_LINE2); } if (t.type == DRAW_TREND) { g.setColor(t.color); } //if (mSelectedTrend == t) //{ //g.setColor(C.COLOR_RED); //} if (t != mSelectedTrend && (t.type == DRAW_RECTANGLE || t.type == DRAW_TRIANGLE || t.type == DRAW_ANDREWS_PITCHFORK || t.type == DRAW_ABC || t.type == DRAW_OVAL)) { } else { g.setColor(t.color); g.drawLineDot(t.x[0], t.y[0], t.x[1], t.y[1], t.thickness); } if (t.type == DRAW_FIBO_PROJECTION) { g.drawLine(t.x[1], t.y[1], t.x[2], t.y[2]); } int pointRadiu = 2; if (mSelectedTrend == t) { pointRadiu = 4; selSquareSide = 60; } // draw the point if (t.x[0] >= mX) { g.setColor(0xff00ff00); g.fillRect(t.x[0] - pointRadiu, t.y[0] - pointRadiu, 2 * pointRadiu, 2 * pointRadiu); } if (t.x[1] < mX + getW()) { g.setColor(0xffff5522); g.fillRect(t.x[1] - pointRadiu, t.y[1] - pointRadiu, 2 * pointRadiu, 2 * pointRadiu); } if (t.type == DRAW_FIBO_PROJECTION || t.type == DRAW_TRIANGLE || t.type == DRAW_ANDREWS_PITCHFORK) { if (t.x[2] < mX + getW()) { g.setColor(0xffffff00); g.fillRect(t.x[2] - pointRadiu, t.y[2] - pointRadiu, 2 * pointRadiu, 2 * pointRadiu); } } // draw the dragging point if (mSelectedTrend == t) { g.setColor(C.COLOR_MAGENTA); int r = 4; int cx = (t.x[0] + t.x[1]) / 2; int cy = (t.y[0] + t.y[1]) / 2; g.drawRect(cx - 2, cy - 2, 4, 4); g.drawRect(cx - 5, cy - 5, 10, 10); } // draw fibo lines if (t.type == DRAW_TREND) { drawTrend(g, t); } if (t.type == DRAW_TREND_ARROW) { drawTrendArrow(g, t); } else if (t.type == DRAW_FIBO_RETRACEMENT) { drawFiboRetracementLines(g, t); } else if (t.type == DRAW_FIBO_PROJECTION) { drawFiboProjection(g, t); } else if (t.type == DRAW_FIBO_TIME) { drawFiboTime(g, t); } else if (t.type == DRAW_FIBO_FAN) { drawFiboFan(g, t); } else if (t.type == DRAW_FIBO_ARC) { drawFiboArc(g, t); } else if (t.type == DRAW_RECTANGLE) { drawRectangle(g, t); } else if (t.type == DRAW_TRIANGLE) { drawTriangle(g, t); } else if (t.type == DRAW_OVAL) { drawOval(g, t); } else if (t.type == DRAW_ABC) { drawAbc(g, t); } else if (t.type == DRAW_ANDREWS_PITCHFORK) { drawAndrewsPitchFork(g, t); } if (mSelectedTrend != null) { drawControls(g); } } //==================draw finger square if (mSelectedTrend != null && mSelVertex != -1) { int x = mSelectedTrend.x[0]; int y = mSelectedTrend.y[0]; if (mSelVertex == 1) { x = mSelectedTrend.x[1]; y = mSelectedTrend.y[1]; } else if (mSelVertex == 2) { x = mSelectedTrend.x[2]; y = mSelectedTrend.y[2]; } selSquareSide = 20; g.setColor(C.COLOR_YELLOW); //g.drawRect(x - selSquareSide / 2, y - selSquareSide / 2, selSquareSide, selSquareSide); //x += selSquareSide / 4; //y += selSquareSide / 4; //g.drawRect(x, y, selSquareSide / 2, selSquareSide / 2); if (mSelectedTrend.type != DRAW_FIBO_TIME && mFont != null) { //sprintf(sz, "%d", mSelVertex+1); //g.setColor(C.COLOR_WHITE); //g.drawString(mFont, "" + (mSelVertex + 1), x + 3, y - (int)mFont.GetHeight(), 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); }
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); }
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); }
protected void renderCandle(xGraphics g, stCell c) { int x, y; x = c.x; y = 0; uint color; object o = getUserData(); String code; if (o is String) { code = (String)o; } else { stGainloss gainloss = (stGainloss)o; code = gainloss.code; } if (code == null) { return; } stPriceboardState ps = Context.getInstance().mPriceboard.getPriceboard(code); if (ps == null) { return; } Context ctx = Context.getInstance(); float price = ps.getCurrentPrice(); float open = ctx.mPriceboard.getOpen(ps.getID()); if (open == 0) { open = price; } float hi = ps.getMax(); float lo = ps.getMin(); // check hi/lo valid if ((hi == 0 || lo == 0)) { TradeHistory trade = Context.getInstance().getTradeHistory(ps.getID()); float[] hl = new float[2]; if (trade != null && trade.getHiLo(hl)) { if (hi == 0) { hi = hl[0]; } if (lo == 0) { lo = hl[1]; } } } if (hi == lo) { hi = price; } if (hi == 0) { hi = open > price ? open : price; } if (lo == 0) { lo = open < price ? open : price; } if (lo == 0) { lo = hi; } //--------------------------------------------- float priceLen = (float)(hi - lo); int y0 = 0; float min = ps.getRef() - (ps.getRef() / 13); // +-7% (7*13==100) float max = ps.getRef() + (ps.getRef() / 13); if (ps.getMarketID() == 1) { min = ps.getRef() - (ps.getRef() / 19); // +-5% max = ps.getRef() + (ps.getRef() / 19); } if (min > lo && lo > 0) { min = (float)lo; } if (max < hi) { max = (float)hi; } float totalPrice = (max - min); //(10%); if (totalPrice < priceLen) { totalPrice = priceLen; } if (totalPrice == 0) { return; } float ry = (float)(getH() - 2 * y0) / totalPrice; int totalH = (int)(ry * totalPrice); int bodyW = c.w / 2; //================frame============================= // line _ref g.setColor(0x70ffff00); y = (int)(y0 + totalH - (ps.getRef() - min) * ry); g.drawLineDotHorizontal(c.x + 1, y, c.w - 2); //=================================================== if (price == 0) { return; // khong co giao dich } color = price < open ? C.COLOR_RED : C.COLOR_GREEN; if (price == open) { color = C.COLOR_WHITE; } // draw shadow g.setColor(C.COLOR_WHITE); x = c.x + c.w / 2; if (lo > 0 && hi > 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); }
public override void render(xGraphics g) { if (isFocus()) g.setColor(0xff306AC5); else g.setColor(C.COLOR_BLACK); g.clear(); g.setColor(C.COLOR_GRAY_LIGHT); g.drawLine(0, 0, getW(), 0); g.setColor(C.COLOR_GRAY_LIGHT); g.drawLine(0, getH()-2, getW(), getH()-2); 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); */ int iconIdx = mMarketID == 1 ? 0 : 1; g.drawImage(mIcons.Images[iconIdx], 0, 1); x = mIcons.ImageSize.Width + 1; 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 = 77; // 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; if (pi.changed_point >= 0) sb.AppendFormat("(+{0}, {1})", s1, s2); else sb.AppendFormat("(-{0}, {1})", s1, s2); s = sb.ToString(); g.drawString(mFont, s, x, y); x = 160; // KL g.setColor(C.COLOR_WHITE); s = Utils.formatNumber((int)pi.total_volume); sb.Length = 0; sb.AppendFormat("KL:{0:F1} tr", (double)(pi.total_volume/1000000)); g.drawString(mFont, sb.ToString(), x, y); x = 245; // GT sb.Length = 0; sb.AppendFormat("GT:{0:F1} tỷ", (double)pi.totalGTGD/1000); g.drawString(mFont, sb.ToString(), x, y); /* x = 520; // 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.floor_cnt, 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); */ }