예제 #1
0
        public override void GetMinMaxValues(ChartControl chartControl, ref double min, ref double max)
        {
            if (Bars == null)
            {
                return;
            }

            int lastBar  = Math.Min(this.LastBarIndexPainted, Bars.Count - 1);
            int firstBar = this.FirstBarIndexPainted;

            min = Double.MaxValue;
            max = Double.MinValue;

            for (int index = firstBar; index <= lastBar; index++)
            {
                if ((index <= lastcalcbar) && (index >= Math.Max(1, startbar)))
                {
                    min = Math.Min(min, HALow.Get(index));
                    max = Math.Max(max, HAHigh.Get(index));
                }
            }

            if ((max - min) < 1)
            {
                min -= 1;
                max += 1;
            }
        }
예제 #2
0
        public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
        {
            base.Plot(graphics, bounds, min, max);

            if (Bars == null)
            {
                return;
            }

            int lastBar  = Math.Min(this.LastBarIndexPainted, Bars.Count - 1);
            int firstBar = this.FirstBarIndexPainted;

            int x, yHigh, yClose, yOpen, yLow;

            using (Pen drawPen = new Pen(Color.Transparent, ShadowWidth), HiLoPen = new Pen(hiloBarColor))
            {
                for (int index = firstBar; index <= lastBar; index++)
                {
                    if ((index <= lastcalcbar) && (index >= Math.Max(1, startbar)))
                    {
                        x      = ChartControl.GetXByBarIdx(BarsArray[0], index);
                        yHigh  = ChartControl.GetYByValue(this, HAHigh.Get(index));
                        yClose = ChartControl.GetYByValue(this, HAClose.Get(index));
                        yOpen  = ChartControl.GetYByValue(this, HAOpen.Get(index));
                        yLow   = ChartControl.GetYByValue(this, HALow.Get(index));

                        if (Direction.Get(index) > 0)
                        {
                            drawPen.Color = BarColorUp;
                        }
                        else if (Direction.Get(index) < 0)
                        {
                            drawPen.Color = BarColorDown;
                        }
                        else
                        {
                            drawPen.Color = BarColorWarn;
                        }

                        graphics.DrawLine(HiLoPen, x, yHigh, x, yLow);
                        graphics.DrawLine(drawPen, x, yOpen, x, yClose);
                    }
                }
            }
        }
예제 #3
0
        public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
        {
            if (Bars == null || ChartControl == null)
            {
                return;
            }

            int barPaintWidth = Math.Max(3, 1 + 2 * ((int)Bars.BarsData.ChartStyle.BarWidth - 1) + 2 * shadowWidth);

            for (int idx = FirstBarIndexPainted; idx <= LastBarIndexPainted; idx++)
            {
                if (idx - Displacement < 0 || idx - Displacement >= BarsArray[0].Count || (!ChartControl.ShowBarsRequired && idx - Displacement < BarsRequired))
                {
                    continue;
                }
                double valH = HAHigh.Get(idx);
                double valL = HALow.Get(idx);
                double valC = HAClose.Get(idx);
                double valO = HAOpen.Get(idx);
                int    x    = ChartControl.GetXByBarIdx(BarsArray[0], idx);
                int    y1   = ChartControl.GetYByValue(this, valO);
                int    y2   = ChartControl.GetYByValue(this, valH);
                int    y3   = ChartControl.GetYByValue(this, valL);
                int    y4   = ChartControl.GetYByValue(this, valC);

                graphics.DrawLine(shadowPen, x, y2, x, y3);

                if (y4 == y1)
                {
                    graphics.DrawLine(shadowPen, x - barPaintWidth / 2, y1, x + barPaintWidth / 2, y1);
                }
                else
                {
                    if (y4 > y1)
                    {
                        graphics.FillRectangle(brushDown, x - barPaintWidth / 2, y1, barPaintWidth, y4 - y1);
                    }
                    else
                    {
                        graphics.FillRectangle(brushUp, x - barPaintWidth / 2, y4, barPaintWidth, y1 - y4);
                    }
                    graphics.DrawRectangle(shadowPen, (x - barPaintWidth / 2) + (shadowPen.Width / 2), Math.Min(y4, y1), barPaintWidth - shadowPen.Width, Math.Abs(y4 - y1));
                }
            }
        }
예제 #4
0
        public override void GetMinMaxValues(ChartControl chartControl, ref double min, ref double max)
        {
            if (Bars == null || ChartControl == null)
            {
                return;
            }

            for (int idx = FirstBarIndexPainted; idx <= LastBarIndexPainted; idx++)
            {
                double tmpHigh = HAHigh.Get(idx);
                double tmpLow  = HALow.Get(idx);

                if (tmpHigh != 0 && tmpHigh > max)
                {
                    max = tmpHigh;
                }
                if (tmpLow != 0 && tmpLow < min)
                {
                    min = tmpLow;
                }
            }
        }