public static CandleTimeSeriesPlotInfo Create(
            CandleTimeSeries series    = null,
            Color?increasingColor      = null,
            Color?decreasingColor      = null,
            string title               = null,
            Color?backgroundColor      = null,
            bool positiveCandlesHollow = true)
        {
            CandleTimeSeriesPlotInfo info = new CandleTimeSeriesPlotInfo
            {
                Series          = series,
                IncreasingColor = increasingColor
                                  ?? Color.Black,
                DecreasingColor = decreasingColor
                                  ?? Color.Red,
                BackgroundColor = backgroundColor
                                  ?? Color.White,
                PositiveCandlesHollow = positiveCandlesHollow,
            };

            if (!string.IsNullOrEmpty(title))
            {
                info.Title = title;
            }
            else
            {
                string alternativeTitle = series?.Name;
                info.Title = string.IsNullOrEmpty(alternativeTitle)
                    ? "NO NAME"
                    : alternativeTitle;
            }

            return(info);
        }
        public static void Plot(CandleTimeSeriesPlotInfo info)
        {
            PlotView view = GetPlotView(info);

            Form form = new Form();

            form.Controls.Add(view);
            form.ShowDialog();
        }
        public static PlotView GetPlotView(CandleTimeSeriesPlotInfo info
                                           , Action <object, AxisChangedEventArgs> onAxisChangedMethod = null)
        {
            List <HighLowItem> items = info.Series.Candles
                                       .OrderBy(candle => candle.Start)
                                       .Select(candle => new HighLowItem()
            {
                X     = DateTimeAxis.ToDouble(candle.Start),
                Open  = candle.Open,
                Close = candle.Close,
                High  = candle.Max,
                Low   = candle.Min,
            })
                                       .ToList();
            CandleStickSeries series = new CandleStickSeries
            {
                RenderInLegend = true,
                Title          = info.Title,
                Background     = OxyColor.FromArgb(
                    info.BackgroundColor.A,
                    info.BackgroundColor.R,
                    info.BackgroundColor.G,
                    info.BackgroundColor.B),
                //CandleWidth = info.CandleWidth,
                IsVisible       = true,
                DecreasingColor = OxyColor.FromArgb(
                    info.DecreasingColor.A,
                    info.DecreasingColor.R,
                    info.DecreasingColor.G,
                    info.DecreasingColor.B),
                IncreasingColor = OxyColor.FromArgb(
                    info.IncreasingColor.A,
                    info.IncreasingColor.R,
                    info.IncreasingColor.G,
                    info.IncreasingColor.B),
                Color = OxyColor.FromArgb(
                    info.BackgroundColor.A,
                    info.BackgroundColor.R,
                    info.BackgroundColor.G,
                    info.BackgroundColor.B),
                ItemsSource = items,
                //Hollow = info.PositiveCandlesHollow,
            };

            PlotModel model = new PlotModel();

            model.Axes.Clear();
            DateTimeAxis timeAxis = new DateTimeAxis();

            if (onAxisChangedMethod != null)
            {
                timeAxis.AxisChanged += onAxisChangedMethod.Invoke;
            }
            model.Axes.Add(timeAxis);
            model.Series.Clear();
            model.Series.Add(series);
            PlotView view = new PlotView
            {
                Model = model,
                Dock  = DockStyle.Fill,
            };

            return(view);
        }