Exemple #1
0
        public void Analyze(Broker bro, Symbol sym, string date)
        {
            #region Init
            Quotes q1 = null;

            #region Check
            for (int i = 0; i < bro.Symbols.Count; i++)
                if (bro.Symbols[i].Name == sym.Name)
                {
                    for (int j = 0; j < bro.Symbols[i].Files.Count; j++)
                        if (bro.Symbols[i].Files[j].Date == date)
                        {
                            q1 = new Quotes(bro.Symbols[i].Files[j].Path);
                            i = bro.Symbols.Count;
                            break;
                        }
                }

            if (q1 == null || q1.pTime == null)
            {
                //Log(bro1.Name, "", sym.Name, new MegaTime(date), false);
                return;
            }
            #endregion
            #endregion

            bool isSos = false;
            MegaTime t = null;
            int Ticks = (int)numericUpDown1.Value;
            int Delta = (int)numericUpDown3.Value;
            int asum1 = 0, asum2 = 0;
            int sum1 = 0, sum2 = 0;
            bool fl = false;

            for (int i = Ticks + 1; i < q1.pTime.Count; i++)
            {
                asum1 = 0;
                asum2 = 0;
                sum1 = 0;
                sum2 = 0;
                fl = false;

                for (int j = 0; j < Ticks; j++)
                {
                    sum1 += q1.pAsk[i - j] - q1.pAsk[i - j - 1];
                    sum2 += q1.pBid[i - j] - q1.pBid[i - j - 1];
                    asum1 += Math.Abs(sum1);
                    asum2 += Math.Abs(sum2);

                    if (checkBox3.Checked && asum1 / Math.Max(Math.Abs(sum1), 1) >= Delta && asum2 / Math.Max(Math.Abs(sum2), 1) >= Delta)
                    {
                        if (!isSos)
                        {
                            isSos = true;
                            t = new MegaTime(q1.pTime[i - Ticks]);
                        }
                        fl = true;
                    }
                    else if (!checkBox3.Checked && (asum1 / Math.Max(Math.Abs(sum1), 1) >= Delta || asum2 / Math.Max(Math.Abs(sum2), 1) >= Delta))
                    {
                        if (!isSos)
                        {
                            isSos = true;
                            t = new MegaTime(q1.pTime[i - Ticks]);
                        }
                        fl = true;
                    }
                }

                if (!fl)
                {
                    if (isSos)
                    {
                        Log(bro.Name, sym.Name, t, true);
                        isSos = false;
                    }
                }
            }
        }
Exemple #2
0
 public void Log(string bro1, string sym, MegaTime time, bool bt)
 {
     dataGridView1.Rows.Add();
     dataGridView1[0, dataGridView1.Rows.Count - 1].Value = bro1;
     dataGridView1[1, dataGridView1.Rows.Count - 1].Value = sym;
     dataGridView1[2, dataGridView1.Rows.Count - 1].Value = time;
     if (bt)
     {
         dataGridView1[3, dataGridView1.Rows.Count - 1].Value = "Взглянуть";
     }
     else
     {
         dataGridView1[3, dataGridView1.Rows.Count - 1].Value = "ERROR";
     }
 }