コード例 #1
0
        private void CalculateCandleSpacing()
        {
            ChartX       = _series._chartPanel._chartX;
            ChartX._xMap = new double[ChartX._xCount = 0];

            int rcnt = ChartX.VisibleRecordCount;

            double x2    = ChartX.GetXPixel(rcnt);
            double x1    = ChartX.GetXPixel(rcnt - 1);
            double space = ((x2 - x1) / 2) - ChartX._barWidth / 2;

            if (space > 0.0)
            {
                if (space > 20)
                {
                    space = 20;
                }
                space = space * 0.75; //25%
            }
            else
            {
                space = 1;
            }

            ChartX._barSpacing = space;

            double wick = ChartX._barWidth;

            _halfwick = wick / 2;
        }
コード例 #2
0
        /// <summary>
        /// Sets chart value lookup based on actual pixel position
        /// </summary>
        internal void Update()
        {
            if (_chartPanel == null)
            {
                return;
            }

            _x1 = _chartX.GetXPixel(_x1Value - _chartX._startIndex, true);
            _x2 = _chartX.GetXPixel(_x2Value - _chartX._startIndex, true);
            _y1 = _chartPanel.GetY(_y1Value);
            _y2 = _chartPanel.GetY(_y2Value);
        }
コード例 #3
0
ファイル: Stock.cs プロジェクト: raheemaleem/HCM-Data-Service
        internal void Paint()
        {
            StockChartX chartX = _series._chartPanel._chartX;

            double x1 = chartX.GetXPixel(_index);
            double x2 = x1;
            double y1 = _series._chartPanel.GetY(_high);
            double y2 = _series._chartPanel.GetY(_low);

            SetCurrentBrush();

            //Vertical line
            if (_high != _low)
            {
                PaintLine(x1, y1, x2, y2, 0, true);
                if (_brushMustBeChanged)
                {
                    _lines[0].Stroke = _currentBrush;
                }
            }
            else
            {
                PaintLine(0, 0, 0, 0, 0, false);
            }

            // try to paint left half wick - line
            if (_open.HasValue && _series._seriesType != SeriesTypeEnum.stStockBarChartHLC)
            {
                x2 = x1 - _space;
                y1 = _series._chartPanel.GetY(_open.Value);
                PaintLine(x1, y1, x2, y1, 1, true);
                if (_brushMustBeChanged)
                {
                    _lines[1].Stroke = _currentBrush;
                }
            }
            else
            {
                PaintLine(0, 0, 0, 0, 1, false);
            }

            //paint right half wick - line
            x2 = x1 + _space;
            y1 = _series._chartPanel.GetY(_close);
            PaintLine(x1, y1, x2, y1, 2, true);
            if (_brushMustBeChanged)
            {
                _lines[2].Stroke = _currentBrush;
            }

            _brushMustBeChanged = false;
        }
コード例 #4
0
        //    private void Candle_OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        //    {
        ////      PaintCandle();
        //    }
        //
        //    private void Wick_OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        //    {
        ////      PaintWick();
        //    }

        internal void PaintWick()
        {
            ChartPanel  chartPanel = _series._chartPanel;
            StockChartX chartX     = chartPanel._chartX;

            double x  = chartX.GetXPixel(_index);
            double y1 = _series.GetY(_high);
            double y2 = _series.GetY(_low);

            if (y2 == y1)
            {
                y1 = y2 - 2;
            }

            _lineWick.StrokeThickness = _series._strokeThickness;
            Color color;

            if (_close > _open)
            {
                color = _series._upColor.HasValue ? _series._upColor.Value : _series.StrokeColor;
            }
            else if (_open > _close)
            {
                color = _series._downColor.HasValue ? _series._downColor.Value : _series.StrokeColor;
            }
            else
            {
                color = _series.StrokeColor;
            }

            if (color != _oldWickColor)
            {
                _oldWickColor    = color;
                _lineWick.Stroke = new SolidColorBrush(color);
                _lineWick.Stroke.TryFreeze();
            }

            _lineWick.X1 = x;
            _lineWick.X2 = x;
            _lineWick.Y1 = y1;
            _lineWick.Y2 = y2;

            if (_lineWick.Tag == null)
            {
                _lineWick.Tag = _series;
            }
        }
コード例 #5
0
        //    private void Candle_OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        //    {
        //      PaintCandle();
        //    }
        //
        //    private void Wick_OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        //    {
        //      PaintWick();
        //    }
        //
        internal void PaintWick()
        {
            ChartPanel  chartPanel = _series._chartPanel;
            StockChartX chartX     = chartPanel._chartX;

            CalculateXValues();
            //if (_xHigh == _xLow) return;

            double x  = chartX.GetXPixel(_index);
            double y1 = _series.GetY(_xHigh);
            double y2 = _series.GetY(_xLow);

            if (y2 == y1)
            {
                y1 = y2 - 2;
            }
            _lineWick.StrokeThickness = _series._strokeThickness;
            _lineWick.Stroke          = new SolidColorBrush(_series._strokeColor);
            _lineWick.X1  = _lineWick.X2 = x;
            _lineWick.Y1  = y1;
            _lineWick.Y2  = y2;
            _lineWick.Tag = _series;
        }
コード例 #6
0
        public override bool Paint()
        {
            StockChartX chartX = _series._chartPanel._chartX;

            chartX._psValues1.Clear();
            chartX._psValues2.Clear();
            chartX._psValues3.Clear();

            if (_series.OHLCType != SeriesTypeOHLC.Close)
            {
                return(false);
            }

            Series close = _series;
            Series low   = chartX.GetSeriesOHLCV(_series, SeriesTypeOHLC.Low);

            if (low == null)
            {
                return(false);
            }

            Series high = chartX.GetSeriesOHLCV(_series, SeriesTypeOHLC.High);

            if (high == null)
            {
                return(false);
            }

            /*
             * Initial box top is the high of day 1.
             *
             * The first step is to find a new high that is higher than the high of day 1.
             * The high can be found anytime - even after 5 days.
             * But once the bottom has been found, the box is complete.
             *
             * To find the bottom, the low must be after day 2 of the day the last box
             * top was found and must be lower than the low of original day 1 low.
             *
             * The bottom is always found last and a new high may not be found once
             * the bottom is locked in - the Darvas box is complete then.
             *
             * A new box is started when the price breaks out of top or bottom,
             *
             * The bottom stop loss box is drawn as a percentage of the last price.
             */

            Brush brDarvas            = new SolidColorBrush(Color.FromArgb(0xFF, 0, 0, 255));
            Brush brDarvaseIncomplete = new SolidColorBrush(Color.FromArgb(0xFF, 100, 115, 255));
            Brush topLeft             = new SolidColorBrush(Color.FromArgb(0xFF, 240, 240, 240));
            Brush bottomRight         = new SolidColorBrush(Color.FromArgb(0xFF, 150, 150, 150));
            Brush brGradStopLoss      = Utils.CreateFadeVertBrush(Color.FromArgb(0xFF, 255, 255, 255), Colors.Red);

            double boxTop      = 0;
            double boxBottom   = 0;
            int    bottomFound = 0;
            int    cnt         = 0;
            int    start       = 0;
            int    state       = 0;

            _rects.C = _rects3D.C = _series._chartPanel._rootCanvas;
            _rects3D.Start();
            _rects.Start();

            for (int n = chartX._startIndex; n < chartX._endIndex; n++, cnt++)
            {
                if (!close[n].Value.HasValue || !high[n].Value.HasValue || !low[n].Value.HasValue)
                {
                    continue;
                }

                double x1;
                double x2;
                double y1;
                double y2;
                if (n == chartX._endIndex - 1)
                {
                    x1 = chartX.GetXPixel(start);
                    x2 = chartX.GetXPixel(cnt);
                    y1 = _series._chartPanel.GetY(boxTop);
                    y2 = _series._chartPanel.GetY(boxBottom);

                    if (state == 5) // draw the last COMPLETED box
                    {
                        Rectangle rect = Utils.DrawRectangle(x1, y1, x2 + 2, y2, brDarvas, _rects);
                        rect._rectangle.Opacity = 0.5;

                        Utils.Draw3DRectangle(x1, y1, x2 + 2, y2, topLeft, bottomRight, _rects3D);
                    }
                    else if (bottomFound > 0)
                    {
                        Rectangle rect = Utils.DrawRectangle(x1, y1, x2 + 2, y2, brDarvaseIncomplete, _rects);
                        rect._rectangle.Opacity = 0.5;

                        Utils.Draw3DRectangle(x1, y1, x2 + 2, y2, topLeft, bottomRight, _rects3D);
                    }

                    // Gradient stop loss box
                    double y3 = _series._chartPanel.GetY(boxBottom - (boxBottom * chartX._darvasPct));
                    if (y3 < y2)
                    {
                        y3 = y2;
                    }

                    Utils.DrawRectangle(x1, y2, x2 + 2, y3, brGradStopLoss, _rects);

                    break;
                }

                if (state == 0)
                { // Start of a new box
                  // Save new box top and bottom
                    start       = cnt;
                    bottomFound = 0;
                    boxTop      = high[n].Value.Value;
                    boxBottom   = -1;
                    state       = 1;
                }

                switch (state)
                {
                case 1:
                    if (high[n].Value.Value > boxTop)
                    {
                        boxTop = high[n].Value.Value;
                        state  = 1;
                    }
                    else
                    {
                        state = 2;
                    }
                    break;

                case 2:
                    if (high[n].Value.Value > boxTop)
                    {
                        boxTop = high[n].Value.Value;
                        state  = 1;
                    }
                    else
                    {
                        bottomFound = n;
                        boxBottom   = low[n].Value.Value;
                        state       = 3;
                    }
                    break;

                case 3:
                    if (high[n].Value.Value > boxTop)
                    {
                        boxTop = high[n].Value.Value;
                        state  = 1;
                    }
                    else
                    {
                        if (low[n].Value.Value < boxBottom)
                        {
                            boxBottom   = low[n].Value.Value;
                            bottomFound = n;
                            state       = 3;
                        }
                        else
                        {
                            state = 4;
                        }
                    }
                    break;

                case 4:
                    if (high[n].Value.Value > boxTop)
                    {
                        boxTop = high[n].Value.Value;
                        state  = 1;
                    }
                    else
                    {
                        if (low[n].Value.Value < boxBottom)
                        {
                            boxBottom   = low[n].Value.Value;
                            bottomFound = n;
                            state       = 3;
                        }
                        else
                        {
                            state = 5; // Darvas box is complete
                        }
                    }
                    break;
                }

                if (state != 5)
                {
                    continue;
                }

                if (low[n].Value.Value >= boxBottom && high[n].Value.Value <= boxTop)
                {
                    continue;
                }

                x1 = chartX.GetXPixel(start);
                x2 = chartX.GetXPixel(cnt);
                y1 = _series._chartPanel.GetY(boxTop);
                y2 = _series._chartPanel.GetY(boxBottom);

                Rectangle rectangle = Utils.DrawRectangle(x1, y1, x2, y2, brDarvas, _rects);
                rectangle._rectangle.Opacity = 0.5;

                Utils.Draw3DRectangle(x1, y1, x2, y2, topLeft, bottomRight, _rects3D);

                Utils.DrawRectangle(x1, y2, x2, _series._chartPanel.GetY(boxBottom - (boxBottom * chartX._darvasPct)),
                                    brGradStopLoss, _rects);

                state = 0;
                cnt--;
                n--;
            }

            _rects3D.Stop();
            _rects.Stop();

            _rects.Do(r => r.ZIndex   = ZIndexConstants.DarvasBoxes1);
            _rects3D.Do(r => r.ZIndex = ZIndexConstants.DarvasBoxes2);

            return(true);
        }
コード例 #7
0
        internal void PaintCandle()
        {
            ChartPanel  chartPanel = _series._chartPanel;
            StockChartX chartX     = chartPanel._chartX;

            double x = chartX.GetXPixel(_index);

            Rect   rc;
            double y1;
            double y2;

            if (_rectCandle.Tag == null)
            {
                _rectCandle.Tag = _series;
            }
            if (_open > _close) //down
            {
                y1 = _series.GetY(_open);
                y2 = _series.GetY(_close);
                if (y1 + 3 > y2)
                {
                    y2 += 2;
                }
                rc = new Rect(x - _space - _halfwick, y1, 2 * (_space + _halfwick), y2 - y1);
                if (_brushMustBeChanged)
                {
                    _rectCandle.Fill    = chartX.GetBarBrush(_series.FullName, _index + chartX._startIndex, _down);
                    _brushMustBeChanged = false;
                }
                if (_candleDownOutline == null)
                {
                    _rectCandle.StrokeThickness = 0;
                }
                else
                {
                    _rectCandle.StrokeThickness = 1;
                    _rectCandle.Stroke          = _candleDownOutline;
                }

                //        Canvas.SetLeft(_rectCandle, rc.Left);
                //        Canvas.SetTop(_rectCandle, rc.Top);
            }
            else if (_open < _close) //up
            {
                y1 = _series.GetY(_close);
                y2 = _series.GetY(_open);
                if (y1 + 3 > y2)
                {
                    y2 += 2;
                }
                rc = new Rect(x - _space - _halfwick, y1, 2 * (_space + _halfwick), y2 - y1);
                if (_brushMustBeChanged)
                {
                    _rectCandle.Fill    = chartX.GetBarBrush(_series.FullName, _index + chartX._startIndex, _up);
                    _brushMustBeChanged = false;
                }
                if (_candleUpOutline == null)
                {
                    _rectCandle.StrokeThickness = 0;
                }
                else
                {
                    _rectCandle.StrokeThickness = 1;
                    _rectCandle.Stroke          = _candleUpOutline;
                }
                //        Canvas.SetLeft(_rectCandle, rc.Left);
                //        Canvas.SetTop(_rectCandle, rc.Top);
                //        _rectCandle.Width = rc.Width;
                //        _rectCandle.Height = rc.Height;
            }
            else //No change, flat bar
            {
                y1 = _series.GetY(_close);
                y2 = _series.GetY(_open);
                if (y2 == y1)
                {
                    y1 = y2 - 1;
                }
                rc = new Rect(x - _space - _halfwick, y1, 2 * (_space + _halfwick), y2 - y1);
                if (_brushMustBeChanged)
                {
                    _rectCandle.Fill    = chartX.GetBarBrush(_series.FullName, _index + chartX._startIndex, _down);
                    _brushMustBeChanged = false;
                }
                _rectCandle.StrokeThickness = 0;
                //        Canvas.SetLeft(_rectCandle, rc.Left);
                //        Canvas.SetTop(_rectCandle, rc.Top);
                //        _rectCandle.Width = rc.Width;
                //        _rectCandle.Height = rc.Height;
            }

            _rcTransform.X = rc.Left;
            _rcTransform.Y = rc.Top;
            if (_rectCandle.Width != rc.Width)
            {
                _rectCandle.Width = rc.Width;
            }
            if (_rectCandle.Height != rc.Height)
            {
                _rectCandle.Height = rc.Height;
            }
        }
コード例 #8
0
    public override bool Paint()
    {
      //Find Series
      Series open = _series._chartPanel.GetSeriesOHLCV(_series, SeriesTypeOHLC.Open);
      if (open == null || open.RecordCount == 0 || open.Painted) return false;
      Series high = _series._chartPanel.GetSeriesOHLCV(_series, SeriesTypeOHLC.High);
      if (high == null || high.RecordCount == 0 || high.Painted) return false;
      Series low = _series._chartPanel.GetSeriesOHLCV(_series, SeriesTypeOHLC.Low);
      if (low == null || low.RecordCount == 0 || low.Painted) return false;
      Series close = _series._chartPanel.GetSeriesOHLCV(_series, SeriesTypeOHLC.Close);
      if (close == null || close.RecordCount == 0 || close.Painted) return false;

      open.Painted = high.Painted = low.Painted = close.Painted = true;

      StockChartX chartX = _series._chartPanel._chartX;
      chartX._xMap = new double[chartX._xCount = 0];

      const int iStep = 1;
      int rcnt = chartX.RecordCount;
      double x2 = chartX.GetXPixel(rcnt);
      double x1 = chartX.GetXPixel(rcnt - 1);
      double space = ((x2 - x1) / 2) - chartX._barWidth / 2;
      if (space > 20) space = 20;
      if (space > _series._chartPanel._chartX._barSpacing)
        _series._chartPanel._chartX._barSpacing = space;

      space = Math.Ceiling(space * 0.75);

      Color upColor = _series._upColor.HasValue ? _series._upColor.Value : chartX.UpColor;
      Color downColor = _series._downColor.HasValue ? _series._downColor.Value : chartX.DownColor;
      _upBrush = !chartX.ThreeDStyle
                   ? (Brush)new SolidColorBrush(upColor)
                   : new LinearGradientBrush
                       {
                         StartPoint = new Point(0, 0.5),
                         EndPoint = new Point(1, 0.5),
                         GradientStops =
                           {
                             new GradientStop { Color = upColor, Offset = 0 },
                             new GradientStop { Color = Constants.FadeColor, Offset = 1.25 }
                           }
                       };
      _downBrush = !chartX.ThreeDStyle
                     ? (Brush)new SolidColorBrush(downColor)
                     : new LinearGradientBrush
                         {
                           StartPoint = new Point(0, 0.5),
                           EndPoint = new Point(1, 0.5),
                           GradientStops =
                             {
                               new GradientStop { Color = downColor, Offset = 0 },
                               new GradientStop { Color = Constants.FadeColor, Offset = 1.25 }
                             }
                         };
      if (chartX._candleDownOutlineColor.HasValue)
        _candleDownOutlineBrush = new SolidColorBrush(chartX._candleDownOutlineColor.Value);
      if (chartX._candleUpOutlineColor.HasValue)
        _candleUpOutlineBrush = new SolidColorBrush(chartX._candleUpOutlineColor.Value);

      double wick = chartX._barWidth;
      double halfwick = wick / 2;
      if (halfwick < 1)
        halfwick = 1;

      int n;

      //int t = Environment.TickCount;
      _candles.C = _series._chartPanel._rootCanvas;
      _candles.Start();

      Debug.WriteLine("StartIndex " + chartX._startIndex + " EndIndex " + chartX._endIndex);

      for (n = chartX._startIndex; n < chartX._endIndex; n += iStep)
      {
        if (n == 0 && (!open[n].Value.HasValue || !high[n].Value.HasValue || !low[n].Value.HasValue || !close[n].Value.HasValue))
          continue;
        if (n > 0 && (!open[n].Value.HasValue || !high[n].Value.HasValue || !low[n].Value.HasValue || !close[n].Value.HasValue ||
          !open[n - 1].Value.HasValue || !close[n - 1].Value.HasValue))
          continue;

        CandleHeikinAshi candle = _candles.GetPaintObject(_upBrush, _downBrush);
        candle.Init(_series);
        candle.SetBrushes(_upBrush, _downBrush, _candleUpOutlineBrush, _candleDownOutlineBrush);
        candle.SetValues(open[n], high[n], low[n], close[n], space, halfwick, n - chartX._startIndex);
      }
      _candles.Stop();

      _candles.Do(c => c.ZIndex = ZIndexConstants.PriceStyles1);

      Debug.WriteLine("Candles count " + _candles.Count);

      return true;
    }
コード例 #9
0
        public override bool Paint()
        {
            if (_series._seriesTypeOHLC != SeriesTypeOHLC.Close)
            {
                return(false);
            }

            StockChartX chartX = _series._chartPanel._chartX;
            Series      open   = chartX.GetSeriesOHLCV(_series, SeriesTypeOHLC.Open);
            Series      high   = chartX.GetSeriesOHLCV(_series, SeriesTypeOHLC.High);

            if (high == null || high.Painted || high.RecordCount == 0)
            {
                return(false);
            }

            Series low = chartX.GetSeriesOHLCV(_series, SeriesTypeOHLC.Low);

            if (low == null || low.Painted || low.RecordCount == 0)
            {
                return(false);
            }

            Series close = chartX.GetSeriesOHLCV(_series, SeriesTypeOHLC.Close);

            if (close == null || close.Painted || close.RecordCount == 0)
            {
                return(false);
            }

            high.Painted = low.Painted = close.Painted = true;

            if (!_subscribedToCustomBrush)
            {
                _subscribedToCustomBrush    = true;
                chartX.OnCandleCustomBrush += ChartX_OnCandleCustomBrush;
            }

            bool  changeBrushes = false;
            Color upColor       = _series._upColor.HasValue ? _series._upColor.Value : chartX.UpColor;
            Color downColor     = _series._downColor.HasValue ? _series._downColor.Value : chartX.DownColor;

            if (!_oldUpColor.HasValue || _oldUpColor.Value != upColor)
            {
                _upBrush = new SolidColorBrush(upColor);
                _upBrush.Freeze();
                _oldUpColor   = upColor;
                changeBrushes = true;
            }

            if (!_oldDownColor.HasValue || _oldDownColor.Value != downColor)
            {
                _downBrush = new SolidColorBrush(_series._downColor.HasValue ? _series._downColor.Value : chartX.DownColor);
                _downBrush.Freeze();
                _oldDownColor = downColor;
                changeBrushes = true;
            }

            if (!_oldStrokeColor.HasValue || _oldStrokeColor.Value != _series._strokeColor)
            {
                _customBrush = new SolidColorBrush(_series._strokeColor);
                _customBrush.Freeze();
                _oldStrokeColor = _series._strokeColor;
                changeBrushes   = true;
            }

            int    rcnt  = chartX.RecordCount;
            double x2    = chartX.GetXPixel(rcnt);
            double x1    = chartX.GetXPixel(rcnt - 1);
            double space = ((x2 - x1) / 2) - chartX._barWidth / 2;

            if (space > 20)
            {
                space = 20;
            }

            chartX._barSpacing = space;

            int cnt = 0;

            ((ModulusFE.Stock)_series)._priceStyleStock = this;

            _stocks.C = _series._chartPanel._rootCanvas;
            _stocks.Start();

            for (int n = chartX._startIndex; n < chartX._endIndex; n++, cnt++)
            {
                if (!high[n].Value.HasValue || !low[n].Value.HasValue || !close[n].Value.HasValue)
                {
                    continue;
                }

                PaintObjects.Stock stock = _stocks.GetPaintObject(_upBrush, _downBrush, _customBrush);
                stock.Init(_series);
                if (changeBrushes)
                {
                    stock.SetBrushes(_upBrush, _downBrush, _customBrush);
                }

                stock.SetValues(open != null ? open[n].Value : null, high[n].Value.Value, low[n].Value.Value, close[n].Value.Value, space, n - chartX._startIndex);
            }

            _stocks.Stop();
            _stocks.Do(s => s.ZIndex = ZIndexConstants.PriceStyles1);

            return(true);
        }
コード例 #10
0
        internal void PaintCandle()
        {
            ChartPanel  chartPanel = _series._chartPanel;
            StockChartX chartX     = chartPanel._chartX;

            double x = chartX.GetXPixel(_index);

            Rect   rc;
            double y1;
            double y2;

            CalculateXValues();

            _rectCandle.Tag = _series;
            if (_xOpen > _xClose)
            {
                y1 = _series.GetY(_xOpen);
                y2 = _series.GetY(_xClose);
                if (y1 + 3 > y2)
                {
                    y2 += 2;
                }
                rc = new Rect(x - _space - _halfwick, y1, 2 * (_space + _halfwick), y2 - y1);
                _rectCandle.Fill = chartX.GetBarBrush(_index + chartX._startIndex, _down);
                if (_candleDownOutline == null)
                {
                    _rectCandle.StrokeThickness = 0;
                }
                else
                {
                    _rectCandle.StrokeThickness = 1;
                    _rectCandle.Stroke          = _candleDownOutline;
                }

                Canvas.SetLeft(_rectCandle, rc.Left);
                Canvas.SetTop(_rectCandle, rc.Top);
                _rectCandle.Width  = rc.Width;
                _rectCandle.Height = rc.Height;
            }
            else if (_xOpen < _xClose)
            {
                y1 = _series.GetY(_xClose);
                y2 = _series.GetY(_xOpen);
                if (y1 + 3 > y2)
                {
                    y2 += 2;
                }
                rc = new Rect(x - _space - _halfwick, y1, 2 * (_space + _halfwick), y2 - y1);
                _rectCandle.Fill = chartX.GetBarBrush(_index + chartX._startIndex, _up);
                if (_candleUpOutline == null)
                {
                    _rectCandle.StrokeThickness = 0;
                }
                else
                {
                    _rectCandle.StrokeThickness = 1;
                    _rectCandle.Stroke          = _candleUpOutline;
                }
                Canvas.SetLeft(_rectCandle, rc.Left);
                Canvas.SetTop(_rectCandle, rc.Top);
                _rectCandle.Width  = rc.Width;
                _rectCandle.Height = rc.Height;
            }
            else
            {
                y1 = _series.GetY(_xClose);
                y2 = _series.GetY(_xOpen);
                if (y2 == y1)
                {
                    y1 = y2 - 1;
                }
                rc = new Rect(x - _space - _halfwick, y1, 2 * (_space + _halfwick), y2 - y1);
                _rectCandle.Fill            = chartX.GetBarBrush(_index + chartX._startIndex, _down);
                _rectCandle.StrokeThickness = 0;
                Canvas.SetLeft(_rectCandle, rc.Left);
                Canvas.SetTop(_rectCandle, rc.Top);
                _rectCandle.Width  = rc.Width;
                _rectCandle.Height = rc.Height;
            }
        }