Exemplo n.º 1
0
        protected virtual void Execute_AddMarkerCommand()
        {
            var pos = dateAxis.InverseTransform(this.SelectedPosition.X);

            DateTime dt = OxyPlot.Axes.DateTimeAxis.ToDateTime(pos);

            this.ProjectViewModel.AddMarkerCommand.Execute(dt);
        }
Exemplo n.º 2
0
        public void BuildCandleSeries()
        {
            if (my_candles == null || my_candles.Count == 0)
            {
                return;
            }

            if (plot_view == null || plot_model == null)
            {
                return;
            }

            lock (series_locker)
            {
                has_candles = true;

                if (axis_Y_type == "linear")
                {
                    try
                    {
                        if (my_candles.Count == items_oxy_candles.Count)
                        {
                            Candle last_candle = my_candles.Last();

                            items_oxy_candles[items_oxy_candles.Count - 1] = new HighLowItem()
                            {
                                X     = DateTimeAxis.ToDouble(last_candle.TimeStart),
                                Open  = (double)last_candle.Open,
                                High  = (double)last_candle.High,
                                Low   = (double)last_candle.Low,
                                Close = (double)last_candle.Close,
                            };
                        }
                        else if (my_candles.Count == items_oxy_candles.Count + 1)
                        {
                            Candle last_candle = my_candles.Last();

                            items_oxy_candles.Add(new HighLowItem()
                            {
                                X     = DateTimeAxis.ToDouble(last_candle.TimeStart),
                                Open  = (double)last_candle.Open,
                                High  = (double)last_candle.High,
                                Low   = (double)last_candle.Low,
                                Close = (double)last_candle.Close,
                            });
                        }
                        else
                        {
                            items_oxy_candles = my_candles.Select(x => new HighLowItem()
                            {
                                X     = DateTimeAxis.ToDouble(x.TimeStart),
                                Open  = (double)x.Open,
                                High  = (double)x.High,
                                Low   = (double)x.Low,
                                Close = (double)x.Close,
                            }).ToList();
                        }
                    }
                    catch { return; }
                }

                if (axis_Y_type == "percent")
                {
                    items_oxy_candles = my_candles.Select(x => new HighLowItem()
                    {
                        X     = DateTimeAxis.ToDouble(x.TimeStart),
                        Open  = (double)x.Open,
                        High  = (double)x.High,
                        Low   = (double)x.Low,
                        Close = (double)x.Close,
                    }).ToList();



                    var start_time = DateTimeAxis.InverseTransform(new ScreenPoint(plot_model.PlotArea.Left, plot_model.PlotArea.Top), date_time_axis_X, linear_axis_Y);
                    var end_time   = DateTimeAxis.InverseTransform(new ScreenPoint(plot_model.PlotArea.Right, plot_model.PlotArea.Top), date_time_axis_X, linear_axis_Y);



                    candle_on_screen = items_oxy_candles.Where(x => x.X >= start_time.X && x.X <= end_time.X).ToList();

                    if (candle_on_screen.Count == 0)
                    {
                        return;
                    }

                    items_oxy_candles = items_oxy_candles.Select(x => new HighLowItem()
                    {
                        X     = x.X,
                        Open  = ((candle_on_screen[0].Open * 100 / x.Open) - 100) * -1,
                        High  = ((candle_on_screen[0].Open * 100 / x.High) - 100) * -1,
                        Low   = ((candle_on_screen[0].Open * 100 / x.Low) - 100) * -1,
                        Close = ((candle_on_screen[0].Open * 100 / x.Close) - 100) * -1,
                    }).ToList();
                }
            }
        }