Exemplo n.º 1
0
        public SeriesCollection GetSeriesCollection(string tiker, string skale, string ChartArea, int From, int To, int index)
        {
            SeriesCollection result;

            if (ChartArea == "0")
            {
                result = new SeriesCollection
                {
                    new OhlcSeries()
                    {
                        Title  = tiker,
                        Name   = tiker,
                        Values = new ChartValues <OhlcPoint>()
                    }
                };
            }
            else
            {
                result = new SeriesCollection
                {
                    new LineSeries()
                    {
                        Values        = new ChartValues <double>(),
                        PointGeometry = Geometry.Empty
                    }
                };
            }

            ParamDataService  paramDataService = new ParamDataService();
            List <PointModel> point            = GetListPoint(tiker, skale);

            // Если To == 0 то выводим всю серию
            if (To == 0)
            {
                To = point.Count - 1;
            }

            for (int i = From * index; i <= To * index; i++)
            {
                int ind = 0;
                // По умолчанию для ChartArea0 выводм серию графика цен
                if (ChartArea == "0")
                {
                    result[ind].Values.Add(new OhlcPoint
                    {
                        Close = point[i].Close,
                        High  = point[i].High,
                        Low   = point[i].Low,
                        Open  = point[i].Open
                    });
                    ind++;
                }
                // Выводим индексы на серию Области графика
                foreach (var tmp in paramDataService.GetLavelModels("Index"))
                {
                    string type = paramDataService.GetParamValue(tmp.Id, "ChartArea");
                    string name = paramDataService.GetParamValue(tmp.Id, "Name");

                    if (type == ChartArea)
                    {
                        //int tmpind = GetIndexSeries(result, name);
                        //double tmpval = point[i].IndexPoint.Find(i1 => i1.Name == name).Value[0].Value;

                        AddSeries(result, point[i].IndexPoint.Find(i1 => i1.Name == name).Value, name);

                        //result[tmpind].Values.Add(tmpval);
                        ind++;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        private void GetIndex(List <DateModel> dateModels)
        {
            IndexModel        indexModel       = new IndexModel();
            List <LavelModel> lavelModels      = new List <LavelModel>();
            ParamDataService  paramDataService = new ParamDataService();

            paramDataService.GetDataLevel((item, error) => { if (error != null)
                                                             {
                                                                 return;
                                                             }
                                                             lavelModels = item; });
            foreach (var tmp in lavelModels.FindAll(i => i.ParemtId == lavelModels.Find(i1 => i1.Name == "Index").Id))
            {
                List <ParamModel> tmp2 = paramDataService.GetParam(tmp.Id);
                if (tmp2.Count != 0)
                {
                    string type = tmp2.Find(i => i.Name.Trim() == "Type").Val;
                    switch (type)
                    {
                    case "EMA":
                        //MessageBox.Show("EMA");
                        indexModel.GetEMA(dateModels.Find(i => i.Scale == "60").Points, tmp2);
                        indexModel.GetEMA(dateModels.Find(i => i.Scale == "D").Points, tmp2);
                        break;

                    case "MACD":
                        //MessageBox.Show("MACD");
                        indexModel.GetMACD(dateModels.Find(i => i.Scale == "60").Points, tmp2);
                        //DateTime date = new DateTime(2019, 11, 12, 19, 00, 00);
                        //if (dateModels.Find(i => i.Scale == "60").Points.Last().Date == date) { MessageBox.Show("!"); }
                        indexModel.GetMACD(dateModels.Find(i => i.Scale == "D").Points, tmp2);
                        break;

                    case "FI":
                        //MessageBox.Show("FI");
                        indexModel.GetForceIndex(dateModels.Find(i => i.Scale == "60").Points, tmp2);
                        indexModel.GetForceIndex(dateModels.Find(i => i.Scale == "D").Points, tmp2);
                        break;

                    case "ATR":
                        indexModel.GetATR(dateModels.Find(i => i.Scale == "60").Points, tmp2);
                        indexModel.GetATR(dateModels.Find(i => i.Scale == "D").Points, tmp2);
                        break;

                    case "ADX":
                        indexModel.GetFinamADX(dateModels.Find(i => i.Scale == "60").Points, tmp2);
                        indexModel.GetFinamADX(dateModels.Find(i => i.Scale == "D").Points, tmp2);
                        break;

                    case "CCI":
                        indexModel.GetCCI(dateModels.Find(i => i.Scale == "60").Points, tmp2);
                        indexModel.GetCCI(dateModels.Find(i => i.Scale == "D").Points, tmp2);
                        break;

                    case "PC":
                        indexModel.GetPraceChanel(dateModels.Find(i => i.Scale == "60").Points, tmp2);
                        indexModel.GetPraceChanel(dateModels.Find(i => i.Scale == "D").Points, tmp2);
                        break;
                    }
                }
            }
        }