示例#1
0
        public static List <Aroon> createAroon(int N, List <Price> Price)
        {
            List <Aroon> AROON = new List <Aroon>();

            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[] _aroonUP   = new double[Price.Count];
            double[] _aroonDOWN = 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.Aroon(0, Price.Count - 1, _high, _low, N, out a, out b, _aroonDOWN, _aroonUP);



            for (int x = 0; x < _aroonUP.Count() - a; x++)
            {
                //Debug.WriteLine("UP " + _aroonUP[x]);
                //Debug.WriteLine("DOWN " + _aroonDOWN[x]);
                //Debug.WriteLine(Price[x + a].TimeStamp + "   " + Price[x + a].Close);
                //Debug.WriteLine("========" + x + "===========");
                int   d  = x + a;
                Aroon aa = new Aroon();
                aa.Aroon_Up   = _aroonUP[x];
                aa.Aroon_Down = _aroonDOWN[x];
                aa.N          = N;
                aa.TimeStamp  = Price[d].TimeStamp;

                aa.Price_Close = Price[d].Close;
                aa.Price_High  = Price[d].High;
                aa.Price_Low   = Price[d].Low;
                aa.Price_Open  = Price[d].Open;
                AROON.Add(aa);
            }



            return(AROON);
        }
        /// <summary>
        /// Calculates Aroon
        /// </summary>
        /// <param name="N">Period</param>
        /// <param name="prices">Prices must NOT be reversed</param>
        /// <returns>List of Aroon</returns>

        public static List<Aroon> getManualAroon(int N, List<Price> prices)
        {
            List<Aroon> aroon = new List<AlsiUtils.Aroon>();
            prices.Reverse();


            double lastcount = 0;
            List<double> CheckListDown = new List<double>();
            List<double> CheckListUP = new List<double>();
            for (int x = 0; x < prices.Count - N; x++)
            {

                Aroon a = new Aroon();

                #region Aroon Down

                double low = prices[x].Low;
                for (int y = x; y < x + N; y++)
                {
                    CheckListDown.Add(prices[y].Low);
                    if (prices[y].Low <= low) low = prices[y].Low;

                }

                lastcount = 0;
                foreach (double d in CheckListDown)
                {
                    lastcount++;
                    if (d == low) break;
                }
                double aroonDown = 100 * (((double)N - lastcount) / (double)N);

                CheckListDown.Clear();
                // Debug.WriteLine(prices[x].TimeStamp + "  " + prices[x].Low + "  " + "low " + low + "   Per " + lastcount);
                //Debug.WriteLine(prices[x].TimeStamp + " Aroon Down " + aroonDown);

                #endregion

                #region Aroon Up

                double up = prices[x].High;
                for (int y = x; y < x + N; y++)
                {
                    CheckListUP.Add(prices[y].High);
                    if (prices[y].High >= up) up = prices[y].High;

                }

                lastcount = 0;
                foreach (double d in CheckListUP)
                {
                    lastcount++;
                    if (d == up) break;
                }
                double aroonup = 100 * (((double)N - lastcount + 1) / (double)N);

                CheckListUP.Clear();
                // Debug.WriteLine(prices[x].TimeStamp + "  " + prices[x].High + "  " + "up " + up + "   Per " + lastcount);
                //Debug.WriteLine(prices[x].TimeStamp + " Aroon Up " + aroonup);
                #endregion
                if (x > 0)
                {
                    a.N = N;
                    a.TimeStamp = prices[x - 1].TimeStamp;
                    a.Aroon_Down = aroonDown;
                    a.Aroon_Up = aroonup;
                    a.Price_Close = prices[x - 1].Close;
                    a.Price_High = prices[x - 1].High;
                    a.Price_Low = prices[x - 1].Low;
                    a.Price_Open = prices[x - 1].Open;
                    aroon.Add(a);
                }

            }


            prices.Reverse();
            return aroon;
        }
示例#3
0
        /// <summary>
        /// Calculates Aroon
        /// </summary>
        /// <param name="N">Period</param>
        /// <param name="prices">Prices must NOT be reversed</param>
        /// <returns>List of Aroon</returns>

        public static List <Aroon> getManualAroon(int N, List <Price> prices)
        {
            List <Aroon> aroon = new List <AlsiUtils.Aroon>();

            prices.Reverse();


            double        lastcount     = 0;
            List <double> CheckListDown = new List <double>();
            List <double> CheckListUP   = new List <double>();

            for (int x = 0; x < prices.Count - N; x++)
            {
                Aroon a = new Aroon();

                #region Aroon Down

                double low = prices[x].Low;
                for (int y = x; y < x + N; y++)
                {
                    CheckListDown.Add(prices[y].Low);
                    if (prices[y].Low <= low)
                    {
                        low = prices[y].Low;
                    }
                }

                lastcount = 0;
                foreach (double d in CheckListDown)
                {
                    lastcount++;
                    if (d == low)
                    {
                        break;
                    }
                }
                double aroonDown = 100 * (((double)N - lastcount) / (double)N);

                CheckListDown.Clear();
                // Debug.WriteLine(prices[x].TimeStamp + "  " + prices[x].Low + "  " + "low " + low + "   Per " + lastcount);
                //Debug.WriteLine(prices[x].TimeStamp + " Aroon Down " + aroonDown);

                #endregion

                #region Aroon Up

                double up = prices[x].High;
                for (int y = x; y < x + N; y++)
                {
                    CheckListUP.Add(prices[y].High);
                    if (prices[y].High >= up)
                    {
                        up = prices[y].High;
                    }
                }

                lastcount = 0;
                foreach (double d in CheckListUP)
                {
                    lastcount++;
                    if (d == up)
                    {
                        break;
                    }
                }
                double aroonup = 100 * (((double)N - lastcount + 1) / (double)N);

                CheckListUP.Clear();
                // Debug.WriteLine(prices[x].TimeStamp + "  " + prices[x].High + "  " + "up " + up + "   Per " + lastcount);
                //Debug.WriteLine(prices[x].TimeStamp + " Aroon Up " + aroonup);
                #endregion
                if (x > 0)
                {
                    a.N           = N;
                    a.TimeStamp   = prices[x - 1].TimeStamp;
                    a.Aroon_Down  = aroonDown;
                    a.Aroon_Up    = aroonup;
                    a.Price_Close = prices[x - 1].Close;
                    a.Price_High  = prices[x - 1].High;
                    a.Price_Low   = prices[x - 1].Low;
                    a.Price_Open  = prices[x - 1].Open;
                    aroon.Add(a);
                }
            }


            prices.Reverse();
            return(aroon);
        }
		public static List<Aroon> createAroon(int N, List<Price> Price)
		{
			List<Aroon> AROON = new List<Aroon>();

			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[] _aroonUP = new double[Price.Count];
			double[] _aroonDOWN = 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.Aroon(0, Price.Count - 1, _high, _low, N, out a, out b, _aroonDOWN, _aroonUP);





			for (int x = 0; x < _aroonUP.Count() - a; x++)
			{
				//Debug.WriteLine("UP " + _aroonUP[x]);
				//Debug.WriteLine("DOWN " + _aroonDOWN[x]);
				//Debug.WriteLine(Price[x + a].TimeStamp + "   " + Price[x + a].Close);
				//Debug.WriteLine("========" + x + "===========");
				int d = x + a;
				Aroon aa = new Aroon();
				aa.Aroon_Up = _aroonUP[x];
				aa.Aroon_Down = _aroonDOWN[x];
				aa.N = N;
				aa.TimeStamp = Price[d].TimeStamp;

				aa.Price_Close = Price[d].Close;
				aa.Price_High = Price[d].High;
				aa.Price_Low = Price[d].Low;
				aa.Price_Open = Price[d].Open;
				AROON.Add(aa);
			}







			return AROON;
		}