Пример #1
0
        private void dgvList_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex < 0 || e.RowIndex < 0)
            {
                return;
            }

            ForceCandlePattern forcePattern = forcePatterns[selectedType];

            S_CandleItemData data = dgvList.Rows[e.RowIndex].Tag as S_CandleItemData;

            selCandleData = data;

            if (e.ColumnIndex == 1)
            {
                var pInfo = PatternUtil.GetForcePatternInfo(selCandleData);
                pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval);
                pInfo.Product      = selectedType;
                pInfo.Item         = selectedItem;
                var pList = forcePattern.GetMatchPatterns2(pInfo);

                dgv.Rows.Clear();
                if (pList.Count > 0)
                {
                    lbNoResult.Visible = false;
                }
                else
                {
                    lbNoResult.Visible = true;
                }

                foreach (var p in pList.OrderByDescending(t => t.CandlePatternType2))
                {
                    int idx = dgv.Rows.Add(p.Item
                                           , getIntervalToString(p.TimeInterval)
                                           , p.EndDT.ToString("yy.MM.dd HH:mm")
                                           , Convert.ToString((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType2)));

                    var type = ((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType2));

                    if (type == CandlePatternTypeEnum.Up)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Red;
                    }
                    else if (type == CandlePatternTypeEnum.Down)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Blue;
                    }
                    else if (type == CandlePatternTypeEnum.StrongUp)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Red;
                    }
                    else if (type == CandlePatternTypeEnum.StrongDown)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Blue;
                    }
                    else if (type == CandlePatternTypeEnum.WeakUp)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Red;
                    }
                    else if (type == CandlePatternTypeEnum.WeakDown)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Blue;
                    }

                    dgv.Rows[idx].Tag = p;
                }
            }
            if (e.ColumnIndex == 2)
            {
                var pInfo = PatternUtil.GetForcePatternInfo(selCandleData);
                pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval);
                pInfo.Product      = selectedType;
                pInfo.Item         = selectedItem;

                var pList = forcePattern.GetMatchPatterns3(pInfo);

                dgv.Rows.Clear();
                if (pList.Count > 0)
                {
                    lbNoResult.Visible = false;
                }
                else
                {
                    lbNoResult.Visible = true;
                }

                foreach (var p in pList.OrderByDescending(t => t.CandlePatternType3))
                {
                    int idx = dgv.Rows.Add(p.Item
                                           , getIntervalToString(p.TimeInterval)
                                           , p.EndDT.ToString("yy.MM.dd HH:mm")
                                           , Convert.ToString((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType3)));

                    var type = ((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType3));

                    if (type == CandlePatternTypeEnum.Up)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Red;
                    }
                    else if (type == CandlePatternTypeEnum.Down)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Blue;
                    }
                    else if (type == CandlePatternTypeEnum.StrongUp)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Red;
                    }
                    else if (type == CandlePatternTypeEnum.StrongDown)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Blue;
                    }
                    else if (type == CandlePatternTypeEnum.WeakUp)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Red;
                    }
                    else if (type == CandlePatternTypeEnum.WeakDown)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Blue;
                    }

                    dgv.Rows[idx].Tag = p;
                }
            }
            if (e.ColumnIndex == 3)
            {
                var pInfo = PatternUtil.GetForcePatternInfo(selCandleData);
                pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval);
                pInfo.Product      = selectedType;
                pInfo.Item         = selectedItem;

                var pList = forcePattern.GetMatchPatterns4(pInfo);

                dgv.Rows.Clear();
                if (pList.Count > 0)
                {
                    lbNoResult.Visible = false;
                }
                else
                {
                    lbNoResult.Visible = true;
                }

                foreach (var p in pList.OrderByDescending(t => t.CandlePatternType4))
                {
                    int idx = dgv.Rows.Add(p.Item
                                           , getIntervalToString(p.TimeInterval)
                                           , p.EndDT.ToString("yy.MM.dd HH:mm")
                                           , Convert.ToString((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType4)));

                    var type = ((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType4));

                    if (type == CandlePatternTypeEnum.Up)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Red;
                    }
                    else if (type == CandlePatternTypeEnum.Down)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Blue;
                    }
                    else if (type == CandlePatternTypeEnum.StrongUp)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Red;
                    }
                    else if (type == CandlePatternTypeEnum.StrongDown)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Blue;
                    }
                    else if (type == CandlePatternTypeEnum.WeakUp)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Red;
                    }
                    else if (type == CandlePatternTypeEnum.WeakDown)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Blue;
                    }

                    dgv.Rows[idx].Tag = p;
                }
            }

            chart1.ClearChartLabel("1");
            chart1.ClearChartLabel("2");
            chart1.DisplayChartLabel(data, Color.Black, "1");
            chart1.DisplayView();
        }
Пример #2
0
        void loadSiseDataFromDaemon()
        {
            ForceCandlePattern forcePattern = forcePatterns[selectedType];

            if (cbxProduct.SelectedIndex < 3)
            {
                selectedItem = (cbxItem.SelectedItem as ItemData).Code;
            }
            else
            {
                selectedItem = cbxItem.SelectedItem.ToString().Substring(0, 6);
            }

            sourceDatas = loadData(selectedType, selectedItem, selectedTimeInterval, null, null);

            if (sourceDatas == null || sourceDatas.Count == 0)
            {
                return;
            }

            for (int i = 0; i < sourceDatas.Count; i++)
            {
                int pIdx = i - 1 < 0 ? 0 : i - 1;
                int nIdx = i + 1 == sourceDatas.Count ? i : i + 1;

                sourceDatas[i].PreCandleItem  = sourceDatas[pIdx];
                sourceDatas[i].NextCandleItem = sourceDatas[nIdx];
            }

            this.Invoke(new Action(() =>
            {
                dgvList.Rows.Clear();
                dgv.Rows.Clear();
                lbNoResult.Visible = false;

                for (int i = sourceDatas.Count - 1; i >= sourceDatas.Count - 50; i--)
                {
                    var data = sourceDatas[i];

                    string date = Convert.ToDateTime(data.DTime).ToString("yy.MM.dd HH:mm");

                    int index = dgvList.Rows.Add(date, "찾기2", "찾기3", "찾기4");

                    dgvList.Rows[index].Tag = data;
                    var pInfo          = PatternUtil.GetForcePatternInfo(data);
                    pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval);
                    pInfo.Product      = selectedType;
                    pInfo.Item         = selectedItem;

                    {
                        var pList = forcePattern.GetMatchPatterns2(pInfo);
                        if (pList.Count == 0)
                        {
                            ((DataGridViewButtonCell)dgvList.Rows[index].Cells[1]).Value = "";
                        }
                    }

                    {
                        var pList = forcePattern.GetMatchPatterns3(pInfo);
                        if (pList.Count == 0)
                        {
                            ((DataGridViewButtonCell)dgvList.Rows[index].Cells[2]).Value = "";
                        }
                    }

                    {
                        var pList = forcePattern.GetMatchPatterns4(pInfo);
                        if (pList.Count == 0)
                        {
                            ((DataGridViewButtonCell)dgvList.Rows[index].Cells[3]).Value = "";
                        }
                    }
                }

                dgvList.ClearSelection();

                Display();
            }));
        }