Ejemplo n.º 1
0
        private void timer_Tick(object sender, EventArgs e)
        {
            if (m_Data == null)
            {
                return;
            }


            if (chkSlide.Checked)
            {
                var sample = CandleSample.GenerateRandom(1, DT, 1000, 10, 20, 15, 120.0f);

                m_Data.Add(sample[0]);

                DT = DT.AddSeconds(tbInterval.Text.AsInt(1));

                chart.NotifySeriesChange();
                return;
            }

            foreach (var sample in m_Data.Data)
            {
                sample.OpenPrice  += ExternalRandomGenerator.Instance.NextScaledRandomInteger(-2, +2);
                sample.ClosePrice += ExternalRandomGenerator.Instance.NextScaledRandomInteger(-2, +2);
                sample.HighPrice  += ExternalRandomGenerator.Instance.NextScaledRandomInteger(-2, +2);
                sample.LowPrice   += ExternalRandomGenerator.Instance.NextScaledRandomInteger(-2, +2);
            }

            chart.NotifySeriesChange();
        }
Ejemplo n.º 2
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            m_Data = new CandleTimeSeries("My data", 0);
            //  m_Data.MaxSamples = 10;

            var sd = DateTime.Now.AddSeconds(-500);

            var samples = CandleSample.GenerateRandom(300,
                                                      sd,
                                                      1000,
                                                      10,

                                                      20, 8,

                                                      120.0f);

            samples.ForEach(s => m_Data.Add(s));

            m_Data.Views.Register(new CandleView("Candles", 0));
            m_Data.Views.Register(
                new CandleMidLineView("MidLineHiLo", 1)
            {
                MidLineType = MidLineType.HighLow,
                LineStyle   = new LineStyle {
                    Color = Color.FromArgb(200, 255, 0, 0), Width = 2
                }
            });

            m_Data.Views.Register(
                new CandleMidLineView("MidLineOpCl1", 2)
            {
                MidLineType = MidLineType.OpenClose,
                LineStyle   = new LineStyle {
                    Color = Color.FromArgb(200, 50, 0, 200), Width = 1.5f, DashStyle = System.Drawing.Drawing2D.DashStyle.Dot
                }
            });



            m_Data.Views.Register(new CandleView("Candles2", 0, "MLPane")
            {
                BlackWhite = true
            });
            m_Data.Views.Register(
                new CandleMidLineView("MidLineOpCl2", 1, "MLPane")
            {
                MidLineType = MidLineType.OpenClose,
                LineStyle   = new LineStyle {
                    Color = Color.FromArgb(200, 255, 180, 0), Width = 3f
                }
            });

            //     m_Data.Views.Register( new CandleView("Avg1", 0, "Another Pane0"));
            //     m_Data.Views.Register( new CandleView("Avg2", 0, "Another Pane1"));



            //m_Data.Views.Register( new CandleView("Avg3", 0, "Another Pane2"));
            //m_Data.Views.Register( new CandleView("Avg4", 0, "Another Pane3"));
            //m_Data.Views.Register( new CandleView("Avg5", 0, "Another Pane4"));
            //m_Data.Views.Register( new CandleView("Avg6", 0, "Another Pane5"));


            chart.Series = m_Data;
        }