예제 #1
0
        //================================================================================
        public void LoadData(DataTable_candle candles)
        {
            DateTime dt       = DateTime.Now;
            DateTime prev_dt  = dt;
            DateTime delta_dt = dt;

            chart1.Series["Price"].Points.Clear();
            chart1.Series["Buy"].Points.Clear();
            //chart1.Series["Short"].Points.Clear();
            //chart1.Series["Cover"].Points.Clear();
            int count = period;

            bar_count = candles.Count;
            if (count > candles.Count)
            {
                count = candles.Count;
            }
            for (int i = 0; i < count; i++)
            {
                int            bar    = candles.Count - (count) + i;
                DataRow_candle candle = candles[bar];

                dt = candle.date;
                if (i == 0)
                {
                    //chart1.Series["Price"].Points.AddXY(dt, candle.high);
                    chart1.Series["Price"].Points.AddXY(1, candle.high);

                    chart1.Series["Buy"].Points.AddXY(1, candle.low * 0.9999);
                    //chart1.Series["Short"].Points.AddXY(1, candle.high * 1.0005);
                    //chart1.Series["Cover"].Points.AddXY(1, candle.low * 0.9999);
                }
                else
                {
                    //int mn = dt.Hour * 60 + dt.Minute;
                    //int prev_mn = prev_dt.Hour * 60 + prev_dt.Minute;
                    //int delta_mn = mn - prev_mn;
                    //if (mn < prev_mn) delta_mn = delta_mn + 1440;
                    //double xval = chart1.Series["Price"].Points[i-1].XValue + delta_mn / 1440.0;
                    double xval = chart1.Series["Price"].Points[i - 1].XValue + 1;
                    chart1.Series["Price"].Points.AddXY(i, candle.high);
                    chart1.Series["Price"].Points[i].XValue = xval;

                    chart1.Series["Buy"].Points.AddXY(i, candle.low * 0.9999);
                    chart1.Series["Buy"].Points[i].XValue = xval;
                    //chart1.Series["Short"].Points.AddXY(i, candle.high * 1.0005);
                    //chart1.Series["Short"].Points[i].XValue = xval;
                    //chart1.Series["Cover"].Points.AddXY(i, candle.low * 0.9999);
                    //chart1.Series["Cover"].Points[i].XValue = xval;
                }
                chart1.Series["Price"].Points[i].YValues[1] = candle.low;
                chart1.Series["Price"].Points[i].YValues[3] = candle.open;
                chart1.Series["Price"].Points[i].YValues[2] = candle.close;
                prev_dt = dt;
            }
        }
예제 #2
0
        //--------------------------------------------------------------------------------
        public DataRow_candle Add_Row(DateTime date, double open, double high, double low, double close, int volume)
        {
            DataRow_candle row = (DataRow_candle)NewRow();

            object[] aValues = new object[]
            {
                date, open, high, low, close, volume
            };
            row.ItemArray = aValues;
            Rows.Add(row);
            return(row);
        }
예제 #3
0
        //================================================================================
        public void LoadPoint(int index, DataRow_candle candle)
        {
            if (index <= 0)
            {
                return;
            }
            if (index >= chart1.Series["Price"].Points.Count)
            {
                return;
            }

            double xval = chart1.Series["Price"].Points[index - 1].XValue + 1;

            chart1.Series["Price"].Points[index].XValue     = xval;
            chart1.Series["Price"].Points[index].YValues[0] = candle.high;
            chart1.Series["Price"].Points[index].YValues[1] = candle.low;
            chart1.Series["Price"].Points[index].YValues[3] = candle.open;
            chart1.Series["Price"].Points[index].YValues[2] = candle.close;

            chart1.Series["Buy"].Points[index].YValues[0] = candle.low * 0.9999;
            //chart1.Series["Short"].Points[index].YValues[0] = candle.high * 1.0005;
            //chart1.Series["Cover"].Points[index].YValues[0] = candle.low * 0.9999;
        }
예제 #4
0
 //--------------------------------------------------------------------------------
 public void Remove_Row(DataRow_candle row)
 {
     Rows.Remove(row);
 }
예제 #5
0
 //--------------------------------------------------------------------------------
 public void Add_Row(DataRow_candle row)
 {
     Rows.Add(row);
 }