Example #1
0
        private void FillRenkoChart(List <S_CandleItemData> listCandles, double basePrice)
        {
            if (listCandles == null)
            {
                return;
            }
            int blockSize = 30;

            chart2.Series[0].Points.Clear();
            int candleCount      = 0;
            S_CandleItemData bdc = null;

            foreach (var dc in listCandles)
            {
                int idx = -1;
                if (bdc != null)
                {
                    int renko = PPUtils.GetRenko(dc, bdc, basePrice);
                    if (renko != 0)
                    {
                        int r = Math.Abs(renko);

                        for (int i = 0; i < r; i++)
                        {
                            if (renko > 0)
                            {
                                idx = chart2.Series[0].Points.AddXY(dc.DTime, 1, 0, 0, 1);
                            }
                            else
                            {
                                idx = chart2.Series[0].Points.AddXY(dc.DTime, 1, 0, 1, 0);
                            }

                            chart2.Series[0].Points[idx].Tag = dc;

                            candleCount++;
                        }
                    }
                }
                bdc = dc;
            }

            var chartArea = chart2.ChartAreas[chart2.Series[0].ChartArea];

            chartArea.AxisX.Minimum            = 0;
            chartArea.AxisX.Maximum            = candleCount + 1;
            chartArea.CursorX.AutoScroll       = true;
            chartArea.AxisX.ScaleView.Zoomable = true;
            chartArea.AxisX.ScaleView.SizeType = DateTimeIntervalType.Number;
            int position = candleCount - blockSize;
            int size     = candleCount;

            chartArea.AxisX.ScrollBar.ButtonStyle     = ScrollBarButtonStyles.All;
            chartArea.AxisX.ScaleView.SmallScrollSize = 10;
            chartArea.AxisY2.Maximum = 1.0;
            chartArea.AxisY2.Minimum = 0.0;
            chartArea.AxisY2.Enabled = AxisEnabled.False;
            chartArea.AxisX.ScaleView.Zoom(position, size + 1);
        }