Esempio n. 1
0
        public void SARThread()
        {
            GetHSIData getHSIData = new GetHSIData();
            Thread     thread     = new Thread(new ThreadStart(getHSIData.Run));

            thread.Start();
        }
Esempio n. 2
0
        private void sar(object sender, EventArgs e)
        {
            GetHSIData        getHSIData   = new GetHSIData();
            List <HSIFutures> findByTime   = getHSIData.GetHSIDataList();
            List <HSIFutures> positiveData = new List <HSIFutures>(); //排序后的数组

            for (int i = findByTime.Count - 1; i >= 0; i--)           //此方法为排序方法
            {
                positiveData.Add(findByTime[i]);
            }

            //for (int i = 0; i < positiveData.Count; i++)
            //{
            //    string data = "时间" + positiveData[i].GetDate();
            //    Spcommon.APIDLL.output(data);
            //}



            SAR           sar     = new SAR();
            float         step    = float.Parse(textBox3.Text);
            float         maxStep = float.Parse(textBox4.Text);
            List <Double> sarList = sar.getSARLineDatas(positiveData, step, maxStep);
            List <int>    buy     = new List <int>();
            List <int>    sell    = new List <int>();
            int           number  = 0;

            for (int i = 1; i < positiveData.Count(); i++)
            {
                if (positiveData[i - 1].GetClose() <= sarList[i - 1])
                {
                    if (positiveData[i].GetClose() > sarList[i] && number % 2 == 0)
                    {
                        buy.Add(i);
                        number++;
                    }
                }

                if (positiveData[i - 1].GetClose() >= sarList[i - 1])
                {
                    if (positiveData[i].GetClose() < sarList[i] && number % 2 != 0)
                    {
                        sell.Add(i);
                        number++;
                    }
                }
            }
            String data = sarList.Count() + "######################" + positiveData.Count() + "##################################";

            Spcommon.APIDLL.output(data);

            for (int i = 0; i < sell.Count(); i++)
            {
                String data1 = "买的信号" + positiveData[buy[i]].GetDate() + "--" + "卖的信号" + positiveData[sell[i]].GetDate();
                Spcommon.APIDLL.output(data1);
            }
        }