如果价格为UP / DOWN,如何将库存图表中的栏更改为绿色和红色栏 [英] How to change bars in stockchart to GREEN and RED bars if price is UP/DOWN

查看:66
本文介绍了如果价格为UP / DOWN,如何将库存图表中的栏更改为绿色和红色栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我正在尝试绘制股票图表。我不确定我能不能让它发挥作用。如果以10000万条为例,我无法正确看到整个图表。

I am trying to paint a stock chart. I am not sure if I can make it work any good. I am not able to see the whole chart correctly if putting 10000 thousands bars for example.

正如您在绘制图表时所看到的那样,酒吧并不是在彼此之后。他们有3个大块(日期)。我喜欢彼此之后的酒吧,并且还能正确显示日期。

As you see when painting the chart the bars doesn't come after eachother. They come in 3 chunks(dates). I like the bars to come after eachother and also show the dates correctly.

如果可能的话,我可以指出正确的方向,以便更正确地查看图表?

If possible to point me in the right direction on what settings to put to see the chart more correctly?

1。重要的特征是上涨的价格应该是绿色

1. The important features is that the prices that goes UP should be in GREEN color

2。重要的功能是,DOWN的价格应为红色

2. The important features is that the prices that goes DOWN should be in RED color

3。使条形显示没有空格。现在有3个"块/日期"。日期之间有空格的酒吧。

3. Make the bars show without empty spaces. Now there are 3 "chunks/dates" of bars with spaces between the dates.




如图所示,条形图中的条形图是BLUE,我不知道不明白为什么。

As seen the bars in the chart is BLUE which I don't understand why.

        void createchart()
        {
            // Create a chart and specify its location. 
            chart1.Series.Clear();
            chart1.ChartAreas.Clear();
            chart1.ChartAreas.Add("ChartArea1");
            chart1.Series.Add("Daily");
            chart1.Series.Add("Date");
            chart1.Series[0].ChartType = SeriesChartType.Stock;
            chart1.Series[1].XValueType = ChartValueType.DateTime;
            chart1.ChartAreas["ChartArea1"].BackColor = System.Drawing.Color.Black;

            chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineWidth = 0;
            chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineWidth = 0;
            //Init
            chart1.Series["Daily"].XValueMember = "Day";
            chart1.Series["Daily"].YValueMembers = "High,Low,Open,Close";
            chart1.Series["Daily"].XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.DateTime;
            chart1.Series["Daily"].CustomProperties = "PriceDownColor=Green, PriceUpColor=Red";
            chart1.Series["Daily"]["OpenCloseStyle"] = "Line";
            chart1.Series["Daily"]["ShowOpenClose"] = "Both";
            chart1.DataManipulator.IsStartFromFirst = true;
            chart1.ChartAreas[0].AxisX.ScrollBar.Enabled = true;
            chart1.ChartAreas[0].AxisX.IsLabelAutoFit = true;
            chart1.ChartAreas[0].AxisX.ScaleView.Size = 8;

            chart1.ChartAreas[0].AxisX.LabelStyle.Format = "yyyy-MM-dd";
            chart1.ChartAreas[0].AxisX.Interval = 1;
            chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Months;
            chart1.ChartAreas[0].AxisX.IntervalOffset = 1;

            //Read in symbolfile
            List<String> dataLIST = new List<String>();
            //readinfile("C:/GlobeTrading/MarketData/NYSE/Stocks/Intradata/30 min/sivb.txt", ReadNormalToLower.Normal, out dataLIST);
            dataLIST.Add("01/04/2016,0930,116.67,117.14,115.23,116.73,18200");
            dataLIST.Add("01/04/2016,1000,116.98,117.17,115.75,116.59,16200");
            dataLIST.Add("01/04/2016,1030,116.56,116.65,115.94,116.24,10600");
            dataLIST.Add("01/04/2016,1100,116.24,116.24,115.31,115.67,6300");
            dataLIST.Add("01/04/2016,1130,115.67,117.06,115.67,117,2700");
            dataLIST.Add("01/04/2016,1200,117,117.02,115.92,116.31,7200");
            dataLIST.Add("01/04/2016,1230,116.31,116.79,116.22,116.56,6100");
            dataLIST.Add("01/04/2016,1300,116.52,116.74,115.35,115.44,18700");
            dataLIST.Add("01/04/2016,1330,115.34,115.75,115.3,115.75,6600");
            dataLIST.Add("01/04/2016,1400,115.75,115.97,115.44,115.87,5000");
            dataLIST.Add("01/04/2016,1430,115.87,115.87,115.4,115.66,9800");
            dataLIST.Add("01/04/2016,1500,115.61,115.66,115.27,115.46,12800");
            dataLIST.Add("01/04/2016,1530,115.46,116.57,115.39,116.57,29200");
            dataLIST.Add("01/05/2016,0930,116.39,118.01,116.39,116.99,10100");
            dataLIST.Add("01/05/2016,1000,117.09,117.48,116.44,116.5,3400");
            dataLIST.Add("01/05/2016,1030,116.5,117.16,116.46,117.08,2900");
            dataLIST.Add("01/05/2016,1100,117.08,117.08,115.99,116.17,3700");
            dataLIST.Add("01/05/2016,1130,116.17,116.66,116.17,116.37,2100");
            dataLIST.Add("01/05/2016,1200,116.3,116.35,115.68,115.91,3800");
            dataLIST.Add("01/05/2016,1230,115.91,116.55,115.77,116.49,7600");
            dataLIST.Add("01/05/2016,1300,116.52,116.73,115.9,116.07,3500");
            dataLIST.Add("01/05/2016,1330,116.07,117.06,116.03,116.68,4000");
            dataLIST.Add("01/05/2016,1400,116.49,116.53,115.9,115.98,4300");
            dataLIST.Add("01/05/2016,1430,115.99,116.26,115.98,116.13,3600");
            dataLIST.Add("01/05/2016,1500,116.25,116.55,115.86,116.38,5300");
            dataLIST.Add("01/05/2016,1530,116.35,116.7,116.07,116.57,21900");
            dataLIST.Add("01/06/2016,0930,114.43,116.21,114.16,116.11,12700");
            dataLIST.Add("01/06/2016,1000,116.11,116.46,114.87,115.47,9100");
            dataLIST.Add("01/06/2016,1030,115.42,115.71,115.07,115.71,5900");
            dataLIST.Add("01/06/2016,1100,115.71,116.38,115.35,115.98,4200");
            dataLIST.Add("01/06/2016,1130,116.06,116.19,115.81,115.83,3300");
            dataLIST.Add("01/06/2016,1200,115.53,115.9,115.1,115.21,8200");
            dataLIST.Add("01/06/2016,1230,115.1,115.26,114.75,114.79,9200");
            dataLIST.Add("01/06/2016,1300,114.75,115.15,114.49,115.01,5200");
            dataLIST.Add("01/06/2016,1330,115.1,115.2,114.64,114.65,4400");
            dataLIST.Add("01/06/2016,1400,114.59,114.9,114.41,114.82,6300");
            dataLIST.Add("01/06/2016,1430,114.82,114.9,113.95,114.04,4300");
            dataLIST.Add("01/06/2016,1500,114.11,114.75,113.87,114.69,4700");
            dataLIST.Add("01/06/2016,1530,114.69,114.75,114.3,114.62,14400");


            List <String> allparams = new List<String>(); List<String> allparams2 = new List<String>();
            for (int i = 0; i < dataLIST.Count; i++)
            {
                //01/04/2016,0930,2.34,2.34,2.34,2.34,100
                allparams = new List<String>(dataLIST[i].Split(','));
                if (allparams.Count == 7)
                {
                    allparams2 = new List<String>(allparams[0].Split('/'));
                    if (allparams2.Count == 3)
                    {
                        DateTime date = new DateTime(Convert.ToInt32(allparams2[2]), Convert.ToInt32(allparams2[0]), Convert.ToInt32(allparams2[1]), Convert.ToInt32(allparams[1].Substring(0, 2)), Convert.ToInt32(allparams[1].Substring(2)), 1);
                        double thedate = date.ToOADate(); 

                        double open = Convert.ToDouble(allparams[2]);
                        double high = Convert.ToDouble(allparams[3]);
                        double low = Convert.ToDouble(allparams[4]);
                        double close = Convert.ToDouble(allparams[5]);

                        //"High,Low,Open,Close"
                        chart1.Series[0].Points.AddXY(thedate, high, low, open, close);
                    }
                }
            }
            chart1.ChartAreas[0].AxisX.IsStartedFromZero = false;
            chart1.ChartAreas[0].AxisY.IsStartedFromZero = false;
        }




推荐答案

Hi Silvers11,

Hi Silvers11,

>>如果价格上涨,如何
将库存图表中的条形更改为GREEN和RED条形图/ DOWN

>>How to change bars in stockchart to GREEN and RED bars if price is UP/DOWN

试试这个:

    List<String> allparams = new List<String>(); List<String> allparams2 = new List<String>();
    for (int i = 0; i < dataLIST.Count; i++)
    {
        //01/04/2016,0930,2.34,2.34,2.34,2.34,100
        allparams = new List<String>(dataLIST[i].Split(','));
        if (allparams.Count == 7)
        {
            allparams2 = new List<String>(allparams[0].Split('/'));
            if (allparams2.Count == 3)
            {
                //...

                //"High,Low,Open,Close"
                chart1.Series[0].Points.AddXY(thedate, high, low, open, close);
               
                //set the color
                if (open < close)
                {
                    chart1.Series[0].Points[i].Color = Color.Green;
                }
                if (open > close)
                {
                    chart1.Series[0].Points[i].Color = Color.Red;
                }
            }
        }
    } 


>> make
条形图显示没有空格。现在有3个"块/日期"。日期之间有空格的条形。

>>Make the bars show without empty spaces. Now there are 3 "chunks/dates" of bars with spaces between the dates.

出现此问题的原因是X轴上的日期是连续的,但是,相应的Y轴的值为空。这意味着t 这里
在01/04 / 2016-15:30和01/05 / 2016-09:30之间没有数据。

The reason for this problem is that the date on the X-axis is continuous, however, the value of the corresponding Y-axis is empty. That means there is no data between 01/04/2016-15:30 and 01/05/2016-09:30.

尝试使用ShortTime而不是OAData:

Try to use ShortTime instead of OAData:

    string thedate = date.ToShortTimeString();
    //double thedate = date.ToOADate();


问候,

Stanly


这篇关于如果价格为UP / DOWN,如何将库存图表中的栏更改为绿色和红色栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆