Beispiel #1
0
        private void UpdateChartData(Instrument instrument, TimeFrame timeFrame)
        {
            // Get the data for the chart from the datasource
            var priceData = _dataManager.GetPriceData(instrument.Symbol, timeFrame);

            UpdatePriceChart(priceData);

            _priceSeries.InvalidateParentSurface(RangeMode.ZoomToFit);
        }
        private void UpdatePriceChart()
        {
            PriceData = (IOhlcDataSeries<DateTime, double>)_priceData.ToDiscontinuousSeries(Calendar);
            PriceData.SeriesName = "PriceData";

            // Create a series for the 200 period SMA which will be plotted as a line chart
            Sma200Series = (IXyDataSeries<DateTime, double>) PriceData.ToMovingAverage(200);
            Sma200Series.SeriesName = "200 SMA";

            // Create a series for the 50 period SMA which will be plotted as a line chart
            Sma50Series = (IXyDataSeries<DateTime, double>)PriceData.ToMovingAverage(50);
            Sma50Series.SeriesName = "50 SMA";

            // Update the chart type and timeframe with current settings
            UpdateChartType(_chartType);
            UpdateAnnotations();

            _priceSeries.InvalidateParentSurface(RangeMode.ZoomToFit);
        }
        private void UpdateChartData(BarStyle barStyle)
        {
            PriceSeries priceData = null;

            switch (barStyle)
            {
            case BarStyle.TimeBar:
                priceData = TicksAggregator.GetPriceDataByTimeFrame(_ticks, _selectedTimeFrame, _calendar, out _min, out _max);
                break;

            case BarStyle.VolumeBar:
                priceData = TicksAggregator.GetPriceDataByVolume(_ticks, _selectedVolume, _calendar, _barTimeFrame, out _min, out _max);
                break;

            case BarStyle.RangeBar:
                priceData = TicksAggregator.GetPriceDataByRange(_ticks, _selectedRange, _calendar, _barTimeFrame, out _min, out _max);
                break;
            }

            UpdatePriceChart(priceData);

            _priceSeries.InvalidateParentSurface(RangeMode.ZoomToFit);
        }
        private void UpdatePriceChart(AggregationPriceChart barStyle)
        {
            switch (barStyle)
            {
            case AggregationPriceChart.Count:
                PriceSeries = (IOhlcDataSeries <DateTime, double>)_priceData.AggregateByCount(_selectedCount);
                break;

            case AggregationPriceChart.Time:
                PriceSeries = (IOhlcDataSeries <DateTime, double>)_priceData.AggregateByTime(TimeSpan.FromMinutes(_selectedTimeFrame));
                break;

            case AggregationPriceChart.Volume:
                PriceSeries = (IOhlcDataSeries <DateTime, double>)_priceData.AggregateByVolume(_ticks.Select(x => x.Volume.ToDouble()).ToList(), _selectedVolume);
                break;

            case AggregationPriceChart.Range:
                PriceSeries = (IOhlcDataSeries <DateTime, double>)_priceData.AggregateByRange(_selectedRange);
                break;

            case AggregationPriceChart.Renko:
                PriceSeries = (IOhlcDataSeries <DateTime, double>)_priceData.AggregateByRenko(_selectedBrickSize);
                break;
            }

            PriceSeries.SeriesName = "PriceData";

            // Create a series for the 200 period SMA which will be plotted as a line chart
            Sma200Series            = (IXyDataSeries <DateTime, double>)PriceSeries.ToMovingAverage(200);
            Sma200Series.SeriesName = "200 SMA";

            // Create a series for the 50 period SMA which will be plotted as a line chart
            Sma50Series            = (IXyDataSeries <DateTime, double>)PriceSeries.ToMovingAverage(50);
            Sma50Series.SeriesName = "50 SMA";

            _priceSeries.InvalidateParentSurface(RangeMode.ZoomToFit);
        }