public override void render(xGraphics g) { if (isHiding()) { return; } if (getShare(3) == null) { return; } Share share = getShare(); if (share == null) { return; } if (detectShareCursorChanged()) { share.calcBollinger(); mBBUpperXY = allocMem(mBBUpperXY, mChartLineLength * 2 + 10); mBBLowerXY = allocMem(mBBLowerXY, mChartLineLength * 2 + 10); mCenterXY = allocMem(mCenterXY, mChartLineLength * 2 + 10); mBBLine = allocMem(mBBLine, mChartLineLength * 4 + 10); pricesToYs(share.pBBUpper, share.mBeginIdx, mBBUpperXY, mChartLineLength, share.getLowestPrice(), share.getHighestPrice()); pricesToYs(share.pBBLower, share.mBeginIdx, mBBLowerXY, mChartLineLength, share.getLowestPrice(), share.getHighestPrice()); int j = 0; j = 0; for (int i = 0; i < mChartLineLength; i++) { mBBLine[j++] = mBBUpperXY[2 * i]; mBBLine[j++] = mBBUpperXY[2 * i + 1]; mCenterXY[2 * i] = mBBLowerXY[2 * i]; mCenterXY[2 * i + 1] = (short)((mBBUpperXY[2 * i + 1] + mBBLowerXY[2 * i + 1]) / 2); } mBBLine[j++] = mBBUpperXY[2 * (mChartLineLength - 1)]; // x mBBLine[j++] = mBBLowerXY[2 * (mChartLineLength - 1) + 1]; // y for (int i = mChartLineLength - 1; i >= 0; i--) { mBBLine[j++] = mBBLowerXY[2 * i]; mBBLine[j++] = mBBLowerXY[2 * i + 1]; } mPointCnt = j / 2; } if (mChartLineLength == 0) { return; } int mX = 0; int mY = 0; int mW = getW(); int mH = getH(); g.setColor(mBBColorBG); g.fillShapes(mBBLine, mPointCnt); g.setColor(0xa00080ff); g.drawLinesDot(mCenterXY, mChartLineLength); g.setColor(0xff752922); g.drawLines(mBBUpperXY, mChartLineLength); g.drawLines(mBBLowerXY, mChartLineLength); //================================= int cur = share.getCursor(); if (mShouldDrawValue && cur >= 0 && cur < share.getCandleCount()) { g.setColor(0xffffa0a0); String s1 = formatPrice(share.pBBUpper[cur]); String s2 = formatPrice(share.pBBLower[cur]); StringBuilder sb = Utils.sb; sb.Length = 0; sb.AppendFormat("BB({0},{1}) U:{2} L:{3}", (int)mContext.mOptBBPeriod, (int)mContext.mOptBBD, s1, s2); s1 = sb.ToString(); g.drawString(mFont, s1, 150, 12, 0); } }
public override void render(xGraphics g) { if (isHiding()) { return; } if (getShare(3) == null) { return; } Share share = getShare(); if (share == null) { return; } if (detectShareCursorChanged()) { share.calcEnvelop(); float[] percent = { 110, 105, 102.5f, 100, 97.5f, 95.0f, 90 }; float[] p = share.pTMP; float min = share.getLowestPrice(); float max = share.getHighestPrice(); for (int i = 0; i < 7; i++) { mLines[i] = allocMem(mLines[i], mChartLineLength * 2 + 10); for (int j = 0; j < mChartLineLength; j++) { p[j] = (percent[i] * share.pSMA_Envelop[share.mBeginIdx + j]) / 100; } pricesToYs(p, 0, mLines[i], mChartLineLength, min, max); } } if (mChartLineLength == 0) { return; } int mX = 0; int mY = 0; int mW = getW(); int mH = getH(); uint[] color = { 0xffff00ff, 0xff00a000, 0xffa00000, 0xffff8000, 0xffa00000, 0xff00a000, 0xffff00ff }; bool[] draws = { false, false, false, true, false, false, false }; if (mContext.mOptEnvelopLine0[0]) // 2.5% { draws[2] = draws[4] = true; } if (mContext.mOptEnvelopLine1[0]) // 5% { draws[1] = draws[5] = true; } if (mContext.mOptEnvelopLine2[0]) // 10% { draws[0] = draws[6] = true; } for (int i = 0; i < 7; i++) { if (draws[i]) { g.setColor(color[i]); g.drawLinesDot(mLines[i], mChartLineLength); } } }