Exemplo n.º 1
0
        private void ShowChartClick(object sender, RoutedEventArgs e)
        {
            var security = SelectedSecurity;

            CandleSeries series;

            if (IsRealTime.IsChecked == true)
            {
                var type = CandleType.GetSelectedValue <CandleTypes>().Value;

                switch (type)
                {
                case CandleTypes.TimeFrame:
                    series = new CandleSeries(typeof(TimeFrameCandle), security, TimeFrame.Value.Value.TimeOfDay);
                    break;

                case CandleTypes.Tick:
                    series = new CandleSeries(typeof(TickCandle), security, VolumeCtrl.Text.To <int>());
                    break;

                case CandleTypes.Volume:
                    series = new CandleSeries(typeof(VolumeCandle), security, VolumeCtrl.Text.To <decimal>());
                    break;

                case CandleTypes.Range:
                    series = new CandleSeries(typeof(RangeCandle), security, PriceRange.Value);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            else
            {
                var timeFrame = (TimeSpan)HistoryInterval.SelectedItem;
                series = new CandleSeries(typeof(TimeFrameCandle), security, timeFrame);
            }

            _chartWindows.SafeAdd(series, key =>
            {
                var wnd = new ChartWindow
                {
                    Title = "{0} {1} {2}".Put(security.Code, series.CandleType.Name.Replace("Candle", string.Empty), series.Arg)
                };

                wnd.MakeHideable();

                var area = new ChartArea();
                wnd.Chart.Areas.Add(area);

                var candlesElem = new ChartCandleElement();
                area.Elements.Add(candlesElem);

                series.ProcessCandle += candle => wnd.Chart.Draw(candlesElem, candle);

                return(wnd);
            }).Show();

            _candleManager.Start(series, (DateTime)From.Value, (DateTime)To.Value);
        }
Exemplo n.º 2
0
        private void ShowChartClick(object sender, RoutedEventArgs e)
        {
            var security = SelectedSecurity;

            CandleSeries series;

            if (IsRealTime.IsChecked == true)
            {
                series = new CandleSeries(RealTimeSettings.Settings.CandleType, security, RealTimeSettings.Settings.Arg);
            }
            else
            {
                var timeFrame = (TimeSpan)HistoryInterval.SelectedItem;
                series = new CandleSeries(typeof(TimeFrameCandle), security, timeFrame);
            }

            _chartWindows.SafeAdd(series, key =>
            {
                var wnd = new ChartWindow
                {
                    Title = "{0} {1} {2}".Put(security.Code, series.CandleType.Name.Remove("Candle"), series.Arg)
                };

                wnd.MakeHideable();

                var area = new ChartArea();
                wnd.Chart.Areas.Add(area);

                var candlesElem = new ChartCandleElement();
                area.Elements.Add(candlesElem);

                _candleManager.Processing += (s, candle) =>
                {
                    if (s == series)
                    {
                        wnd.Chart.Draw(candlesElem, candle);
                    }
                };

                return(wnd);
            }).Show();

            if (IsRealTime.IsChecked == true)
            {
                _candleManager.Start(series, DateTime.Today, null);
            }
            else
            {
                _candleManager.Start(series, From.Value, To.Value);
            }
        }
Exemplo n.º 3
0
		private void ShowChartClick(object sender, RoutedEventArgs e)
		{
			var security = SelectedSecurity;

			CandleSeries series;

			if (IsRealTime.IsChecked == true)
			{
				series = new CandleSeries(RealTimeSettings.Settings.CandleType, security, RealTimeSettings.Settings.Arg);
			}
			else
			{
				var timeFrame = (TimeSpan)HistoryInterval.SelectedItem;
				series = new CandleSeries(typeof(TimeFrameCandle), security, timeFrame);
			}

			_chartWindows.SafeAdd(series, key =>
			{
				var wnd = new ChartWindow
				{
					Title = "{0} {1} {2}".Put(security.Code, series.CandleType.Name.Replace("Candle", string.Empty), series.Arg)
				};

				wnd.MakeHideable();

				var area = new ChartArea();
				wnd.Chart.Areas.Add(area);

				var candlesElem = new ChartCandleElement();
				area.Elements.Add(candlesElem);

				series.ProcessCandle += candle => wnd.Chart.Draw(candlesElem, candle);

				return wnd;
			}).Show();

			if (IsRealTime.IsChecked == true)
				_candleManager.Start(series, DateTime.Today, DateTimeOffset.MaxValue);
			else
				_candleManager.Start(series, (DateTimeOffset)From.Value, (DateTimeOffset)To.Value);
		}
Exemplo n.º 4
0
		private void ShowChartClick(object sender, RoutedEventArgs e)
		{
			var security = SelectedSecurity;

			CandleSeries series;

			if (IsRealTime.IsChecked == true)
			{
				var type = CandleType.GetSelectedValue<CandleTypes>().Value;

				switch (type)
				{
					case CandleTypes.TimeFrame:
						series = new CandleSeries(typeof(TimeFrameCandle), security, TimeFrame.Value.Value.TimeOfDay);
						break;
					case CandleTypes.Tick:
						series = new CandleSeries(typeof(TickCandle), security, VolumeCtrl.Text.To<int>());
						break;
					case CandleTypes.Volume:
						series = new CandleSeries(typeof(VolumeCandle), security, VolumeCtrl.Text.To<decimal>());
						break;
					case CandleTypes.Range:
						series = new CandleSeries(typeof(RangeCandle), security, PriceRange.Value);
						break;
					default:
						throw new ArgumentOutOfRangeException();
				}
			}
			else
			{
				var timeFrame = (TimeSpan)HistoryInterval.SelectedItem;
				series = new CandleSeries(typeof(TimeFrameCandle), security, timeFrame);
			}

			_chartWindows.SafeAdd(series, key =>
			{
				var wnd = new ChartWindow
				{
					Title = "{0} {1} {2}".Put(security.Code, series.CandleType.Name.Replace("Candle", string.Empty), series.Arg)
				};

				wnd.MakeHideable();

				var area = new ChartArea();
				wnd.Chart.Areas.Add(area);

				var candlesElem = new ChartCandleElement();
				area.Elements.Add(candlesElem);

				series.ProcessCandle += candle => wnd.Chart.Draw(candlesElem, candle);

				return wnd;
			}).Show();

			_candleManager.Start(series, (DateTime)From.Value, (DateTime)To.Value);
		}