Esempio n. 1
0
        public static List <SlowStoch> createSlowStochastic(int Fast_K, int Slow_K, int Slow_D, List <Price> Price)
        {
            List <SlowStoch> SS = new List <SlowStoch>();

            double[] _close = new double[Price.Count];
            double[] _high  = new double[Price.Count];
            double[] _low   = new double[Price.Count];
            double[] _open  = new double[Price.Count];

            double[] _ssK = new double[Price.Count];
            double[] _ssD = new double[Price.Count];

            for (int x = 0; x < Price.Count; x++)
            {
                _close[x] = Price[x].Close;
                _high[x]  = Price[x].High;
                _low[x]   = Price[x].Low;
                _open[x]  = Price[x].Open;
            }

            int a, b;


            Core.Stoch(0, Price.Count - 1, _high, _low, _close, Fast_K, Slow_K, Core.MAType.Sma, Slow_D, Core.MAType.Sma, out a, out b, _ssK, _ssD);


            //Debug.WriteLine("SSk  " + _ssK.Count());
            //Debug.WriteLine("SSD  " + _ssD.Count());

            int zeroCount = 0;

            for (int x = 0; x < _ssK.Count(); x++)
            {
                if (_ssK[x] == 0)
                {
                    zeroCount++;
                }
            }

            for (int x = 0; x < _ssK.Count() - zeroCount; x++)
            {
                //Debug.WriteLine("SSK " + _ssK[x]);
                //Debug.WriteLine("SSD " + _ssD[x]);
                //Debug.WriteLine(Price[x + zeroCount].TimeStamp + "   " + Price[x + zeroCount].Close);
                //Debug.WriteLine("===================");

                SlowStoch ss = new SlowStoch();
                ss.D              = _ssD[x];
                ss.K              = _ssK[x];
                ss.TimeStamp      = Price[x + zeroCount].TimeStamp;
                ss.Fast_K         = Fast_K;
                ss.Slow_D         = Slow_D;
                ss.Slow_K         = Slow_K;
                ss.Price_Close    = Price[x + zeroCount].Close;
                ss.Price_High     = Price[x + zeroCount].High;
                ss.Price_Low      = Price[x + zeroCount].Low;
                ss.Price_Open     = Price[x + zeroCount].Open;
                ss.InstrumentName = Price[x + zeroCount].InstrumentName;
                SS.Add(ss);
            }

            return(SS);
        }
		public static List<SlowStoch> createSlowStochastic(int Fast_K, int Slow_K, int Slow_D, List<Price> Price)
		{
			List<SlowStoch> SS = new List<SlowStoch>();

			double[] _close = new double[Price.Count];
			double[] _high = new double[Price.Count];
			double[] _low = new double[Price.Count];
			double[] _open = new double[Price.Count];

			double[] _ssK = new double[Price.Count];
			double[] _ssD = new double[Price.Count];

			for (int x = 0; x < Price.Count; x++)
			{
				_close[x] = Price[x].Close;
				_high[x] = Price[x].High;
				_low[x] = Price[x].Low;
				_open[x] = Price[x].Open;

			}

			int a, b;


			Core.Stoch(0, Price.Count - 1, _high, _low, _close, Fast_K, Slow_K, Core.MAType.Sma, Slow_D, Core.MAType.Sma, out a, out b, _ssK, _ssD);


			//Debug.WriteLine("SSk  " + _ssK.Count());
			//Debug.WriteLine("SSD  " + _ssD.Count());

			int zeroCount = 0;
			for (int x = 0; x < _ssK.Count(); x++)
			{
				if (_ssK[x] == 0) zeroCount++;
			}

			for (int x = 0; x < _ssK.Count() - zeroCount; x++)
			{
				//Debug.WriteLine("SSK " + _ssK[x]);
				//Debug.WriteLine("SSD " + _ssD[x]);
				//Debug.WriteLine(Price[x + zeroCount].TimeStamp + "   " + Price[x + zeroCount].Close);
				//Debug.WriteLine("===================");

				SlowStoch ss = new SlowStoch();
				ss.D = _ssD[x];
				ss.K = _ssK[x];
				ss.TimeStamp = Price[x + zeroCount].TimeStamp;
				ss.Fast_K = Fast_K;
				ss.Slow_D = Slow_D;
				ss.Slow_K = Slow_K;
				ss.Price_Close = Price[x + zeroCount].Close;
				ss.Price_High = Price[x + zeroCount].High;
				ss.Price_Low = Price[x + zeroCount].Low;
				ss.Price_Open = Price[x + zeroCount].Open;
				ss.InstrumentName = Price[x + zeroCount].InstrumentName;
				SS.Add(ss);
			}

			return SS;
		}