예제 #1
0
        protected override void CalculateFor(int current)
        {
            HistoricalPriceVolumeEntry entry = HistoricalData.Items[current];
            //            int current = i + 1;

            DateTime date = entry.Date;
            //            int back = current - Period;
            //            back = back < 0 ? 0 : back;

            //            List<HistoricalPriceVolumeEntry> range = HistoricalData.GetPrevAsList(current, BeginCalculationOffset);
            List <HistoricalPriceVolumeEntry> range = GetPrevRange();

            int dayHigh = IndicatorUtils.GetHighestId(range.Select(e => e.High));
            //            int daysSinceHigh = range.Count - dayHigh;
            decimal aroonUp = 100 * (BeginCalculationOffset - dayHigh) / (decimal)BeginCalculationOffset;

            int dayLow = IndicatorUtils.GetLowestId(range.Select(e => e.Low));
            //            int daysSinceLow = range.Count - dayLow;
            decimal aroonDown = 100 * (BeginCalculationOffset - dayLow) / (decimal)BeginCalculationOffset;

            //            Debug.WriteLine("");
            //            Debug.WriteLine($"Date: {date.ToString("d")}");
            //            Debug.WriteLine($"Up: {aroonUp}");
            //            Debug.WriteLine($"Down: {aroonDown}");

            _upItems.Add(new TechnicalIndicatorItem(date, aroonUp));
            _downItems.Add(new TechnicalIndicatorItem(date, aroonDown));
        }
예제 #2
0
        public void Calculate(HistoricalPriceVolume data)
        {
            List <HistoricalPriceVolumeEntry> graph = data.Items;

            for (int i = Period; i < graph.Count; i++)
            {
                HistoricalPriceVolumeEntry entry = graph[i];
                int current = i + 1;

                DateTime date = entry.Date;
                int      back = current - Period;
                back = back < 0 ? 0 : back;

                List <HistoricalPriceVolumeEntry> range = graph.GetRange(i - Period, Period + 1);

                int     dayHigh       = IndicatorUtils.GetHighestId(range.Select(e => e.High));
                int     daysSinceHigh = range.Count - dayHigh;
                decimal aroonUp       = 100 * (Period - daysSinceHigh) / (decimal)Period;

                int     dayLow       = IndicatorUtils.GetLowestId(range.Select(e => e.Low));
                int     daysSinceLow = range.Count - dayLow;
                decimal aroonDown    = 100 * (Period - daysSinceLow) / (decimal)Period;

                Debug.WriteLine("");
                Debug.WriteLine($"Date: {date.ToString("d")}");
                Debug.WriteLine($"Up: {aroonUp}");
                Debug.WriteLine($"Down: {aroonDown}");

                AroonGraph.Add(date, new[] { aroonUp, aroonDown });
            }
        }