private IEnumerable <(TimeSeries, Color)> GetIndicators()
        {
            CandleTimeSeries series = Context.Instance.HistoryCandleTimeSeries.Candles
                                      .ToCandleTimeSeries();

            return(UtilsPresenter.GetIndicators(series, view.IndicatorPeriod, view.SmoothingPeriod));
        }
Ejemplo n.º 2
0
        private void LoadSeriesIndicators(
            AdxInputsPresenter adxInputsPresenter,
            MovingAverageInputsPresenter movingAverageInputsPresenter,
            SeriesIndicatorPresenter seriesPresenter)
        {
            if (view.SelectedDay == DateTime.MinValue)
            {
                return;
            }
            CandleTimeSeries series = Context.Instance.HistoryCandleTimeSeries.Candles
                                      .Where(candle => candle.Start >= view.SelectedDay.Date.AddMonths(-3) &&
                                             candle.Start <= view.SelectedDay.Date)
                                      .ToCandleTimeSeries();
            IEnumerable <(TimeSeries, Color)> indicators = UtilsPresenter.GetIndicators(
                series: Context.Instance.HistoryCandleTimeSeries,
                indicatorPeriod: adxInputsPresenter.GetDxPeriod(),
                smoothingPeriod: adxInputsPresenter.GetMovingAveragePeriod());
            TimeSeries timeSeries = series.Candles
                                    .Select(candle => new DateValue(candle.Start, candle.Close))
                                    .ToTimeSeries();

            TimeSeries slowMovingAverage = timeSeries
                                           .GetExponentialMovingAverage(movingAverageInputsPresenter.SlowMovingAveragePeriod)
                                           .ToTimeSeries("Slow MA");
            TimeSeries mediumMovingAverage = timeSeries
                                             .GetExponentialMovingAverage(movingAverageInputsPresenter.MediumMovingAveragePeriod)
                                             .ToTimeSeries("Medium MA");
            TimeSeries fastMovingAverage = timeSeries
                                           .GetExponentialMovingAverage(movingAverageInputsPresenter.FastMovingAveragePeriod)
                                           .ToTimeSeries("Fast MA");

            seriesPresenter.LoadData(
                series: series,
                indicators: indicators,
                slowMovingAverage: slowMovingAverage,
                mediumMovingAverage: mediumMovingAverage,
                fastMovingAverage: fastMovingAverage
                );
        }