Example #1
0
        public static List <BollingerBand> createBollingerBand(int N, double P, List <Price> Price, Core.MAType MovingAverageType)
        {
            List <BollingerBand> BB = new List <BollingerBand>();


            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[] _upperBand = new double[Price.Count];
            double[] _midBand   = new double[Price.Count];
            double[] _lowerBand = 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.Bbands(0, Price.Count - 1, _close, N, P, P, MovingAverageType, out a, out b, _upperBand, _midBand, _lowerBand);


            for (int x = 0; x < _upperBand.Count() - a; x++)
            {
                //Debug.WriteLine("UPPER " + _upperBand[x]);
                //Debug.WriteLine("MID " + _midBand[x]);
                //Debug.WriteLine("LOWER " + _lowerBand[x]);
                //Debug.WriteLine(Price[x + a].TimeStamp + "   " + Price[x + a].Close);
                //Debug.WriteLine("========" + x + "===========");

                BollingerBand bb = new BollingerBand();
                bb.Mid         = _midBand[x];
                bb.Lower       = _lowerBand[x];
                bb.Upper       = _upperBand[x];
                bb.N           = N;
                bb.P           = P;
                bb.TimeStamp   = Price[x + a].TimeStamp;
                bb.Price_Close = Price[x + a].Close;
                bb.Price_High  = Price[x + a].High;
                bb.Price_Low   = Price[x + a].Low;
                bb.Price_Open  = Price[x + a].Open;
                BB.Add(bb);
            }

            return(BB);
        }
		public static List<BollingerBand> createBollingerBand(int N, double P, List<Price> Price, Core.MAType MovingAverageType)
		{
			List<BollingerBand> BB = new List<BollingerBand>();


			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[] _upperBand = new double[Price.Count];
			double[] _midBand = new double[Price.Count];
			double[] _lowerBand = 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.Bbands(0, Price.Count - 1, _close, N, P, P, MovingAverageType, out a, out b, _upperBand, _midBand, _lowerBand);


			for (int x = 0; x < _upperBand.Count() - a; x++)
			{
				//Debug.WriteLine("UPPER " + _upperBand[x]);
				//Debug.WriteLine("MID " + _midBand[x]);
				//Debug.WriteLine("LOWER " + _lowerBand[x]);
				//Debug.WriteLine(Price[x + a].TimeStamp + "   " + Price[x + a].Close);
				//Debug.WriteLine("========" + x + "===========");

				BollingerBand bb = new BollingerBand();
				bb.Mid = _midBand[x];
				bb.Lower = _lowerBand[x];
				bb.Upper = _upperBand[x];
				bb.N = N;
				bb.P = P;
				bb.TimeStamp = Price[x + a].TimeStamp;
				bb.Price_Close = Price[x + a].Close;
				bb.Price_High = Price[x + a].High;
				bb.Price_Low = Price[x + a].Low;
				bb.Price_Open = Price[x + a].Open;
				BB.Add(bb);
			}

			return BB;
		}