Esempio n. 1
0
        private void GetAnalysis(List <DateModel> dateModels, string tiker)
        {
            IndexModel indexModel = new IndexModel();

            if (dateModels.Find(i => i.Scale == "60").Points.Last().Date.Hour == 19)
            {
                IAnalysis analysis1 = new Analysis1(dateModels.Find(i => i.Scale == "D"), "Analysis1");
                analysis1.GetAnalysis();
            }



            int    item          = dateModels.FindIndex(i => i.Scale == "D");
            int    itemAnalysis1 = dateModels[item].Points.Last().AnalysisResults.FindIndex(i => i.Name == "Analysis1");
            string A1Result      = "";

            if (itemAnalysis1 != -1)
            {
                A1Result = dateModels[item].Points.Last().AnalysisResults[itemAnalysis1].Result;
            }
            else
            {
                int count = dateModels[item].Points.Count();
                itemAnalysis1 = dateModels[item].Points[count - 2].AnalysisResults.FindIndex(i => i.Name == "Analysis1");
                if (itemAnalysis1 != -1)
                {
                    A1Result = dateModels[item].Points[count - 2].AnalysisResults[itemAnalysis1].Result;
                }
                else
                {
                    A1Result = "";
                }
            }

            //if (item >= 0)
            //{
            //    item = dateModels[item].Points.Last().AnalysisResults.FindIndex(i => i.Name == "Analysis1");
            //    if (item >= 0)
            //    {
            //A1Result = dateModels.Find(i => i.Scale == "D").Points.Last().AnalysisResults[item].Result;
            //if (tiker == "GAZP") { }
            Analysis2 analysis2 = new Analysis2(dateModels.Find(i => i.Scale == "60"), "Analysis2", tiker, A1Result);

            analysis2.GetAnalysis();
            // Удаляем ордер если сигнала нет
            int itemDeal = 0;

            if (analysis2.GetResult() == "")
            {
                itemDeal = orderModels.FindIndex(i => i.Tiker == tiker & i.IsActive == true);
                if (itemDeal != -1)
                {
                    orderModels[itemDeal].IsActive = false;
                    orderModels[itemDeal].EndDate  = dateModels[0].Points.Last().Date;
                }
            }
            // проверяем на наличие копий ордера И открытых позиций
            if (analysis2.HaveOrder)
            {
                itemDeal = dealModels.FindIndex(i => i.Tiker == tiker & i.InMarket == true);
                if (itemDeal == -1)
                {
                    itemDeal = orderModels.FindIndex(i => i.Tiker == tiker & i.IsActive == true);
                    if (itemDeal == -1)
                    {
                        orderModels.Add(analysis2.OrderModels);
                    }
                    else
                    {
                        orderModels[itemDeal].Price = analysis2.OrderModels.Price;
                        //orderModels.Add(analysis2.OrderModels);
                    }
                }
            }

            itemDeal = dealModels.FindIndex(i => i.Tiker == tiker & i.InMarket == true);
            if (itemDeal != -1)
            {
                if (A1Result != "")
                {
                    if (dateModels.Find(i => i.Scale == "60").Points.Last().Date.Hour == 19)
                    {
                        //dealModels[itemDeal].StopPrice = dateModels.Find(i => i.Scale == "D").Points.Last().IndexPoint.Find(i => i.Name == "EMA16").Value[0].Value;
                        double tmp  = dateModels.Find(i => i.Scale == "60").Points.Last().IndexPoint.Find(i => i.Name == "ATR").Value.Find(i1 => i1.Name == "ATR").Value;
                        double stop = (indexModel.GetMax(dateModels.Find(i => i.Scale == "60").Points, 22) - (tmp * 2.5));
                        if (stop > 0)
                        {
                            dealModels[itemDeal].StopPrice = stop;
                        }
                        else
                        {
                            dealModels[itemDeal].StopPrice = (indexModel.GetMax(dateModels.Find(i => i.Scale == "60").Points, 22) - (tmp * 2.5));
                        }
                    }
                }
                else
                {
                    //double tmp = dateModels.Find(i => i.Scale == "D").Points.Last().IndexPoint.Find(i => i.Name == "ATR").Value.Find(i1 => i1.Name == "ATR").Value;
                    if (dateModels.Find(i => i.Scale == "60").Points.Last().Date.Hour == 19)
                    {
                        //dealModels[itemDeal].StopPrice = (indexModel.GetMax(dateModels.Find(i => i.Scale == "60").Points, 22) - (tmp * 3));
                        dealModels[itemDeal].StopPrice = dateModels.Find(i => i.Scale == "60").Points.Last().Close;         //IndexPoint.Find(i => i.Name == "EMA8").Value[0].Value;
                    }
                }
                //Analysis3 analysis3 = new Analysis3(dateModels.Find(i => i.Scale == "60"), "Analysis3", tiker, A1Result);
                //analysis3.GetAnalysis();
                //if (analysis3.StopOrder != 0)
                //{
                //    dealModels.Find(i => i.Tiker == tiker & i.InMarket == true).StopPrice = analysis3.StopOrder;
                //}
                //    }
                //}
            }
        }
Esempio 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;
                    }
                }
            }
        }