public override void AddVisualInfo(List <StrategyDataItemInfo> items, string panelName)
        {
            StrategyDataItemInfo info = new StrategyDataItemInfo()
            {
                DataSource = Result,
                FieldName  = "Value",
                Color      = ChartColor,
                ChartType  = ChartType.Line
            };

            if (UseOwnChart)
            {
                info.PanelName = panelName;
            }
            items.Add(info);
        }
Ejemplo n.º 2
0
        protected virtual Series CreatePointSeries(StrategyDataItemInfo info)
        {
            Series s = new Series();

            s.Name = info.Name;
            s.ArgumentDataMember = GetArgumentDataMember(info);
            s.ArgumentScaleType  = GetArgumentScaleType(info);
            s.ValueDataMembers.AddRange(info.FieldName);
            s.ValueScaleType = ScaleType.Numerical;
            PointSeriesView view = new PointSeriesView();

            view.Color = info.Color;
            view.PointMarkerOptions.Size = info.GraphWidth == 1 ? view.PointMarkerOptions.Size : (int)(info.GraphWidth * DpiProvider.Default.DpiScaleFactor);
            s.View       = view;
            s.DataSource = GetDataSource(info);
            return(s);
        }
Ejemplo n.º 3
0
        private XYDiagramPaneBase CheckAddPanel(StrategyDataItemInfo info)
        {
            XYDiagram diagram = (XYDiagram)Chart.Diagram;

            if (diagram == null)
            {
                return(null);
            }
            diagram.AxisY.WholeRange.AlwaysShowZeroLevel = false;
            if (info.PanelName == "Default")
            {
                return(diagram.DefaultPane);
            }
            XYDiagramPane pane = null;

            if (diagram.Panes[info.PanelName] != null)
            {
                pane = diagram.Panes[info.PanelName];
            }

            if (pane == null || info.Reversed)
            {
                SecondaryAxisY axis = new SecondaryAxisY();
                axis.Assign(diagram.AxisY);
                axis.Name    = info.AxisYName;
                axis.Reverse = info.Reversed;
                diagram.SecondaryAxesY.Add(axis);
            }
            if (pane == null)
            {
                pane = new XYDiagramPane()
                {
                    Name = info.PanelName
                };
                diagram.Panes.Add(pane);
                Legend l = new Legend();
                l.Assign(Chart.Legend); l.Name = info.PanelName;
                l.DockTarget = pane;
                Chart.Legends.Add(l);
            }
            if (!info.PanelVisible)
            {
                pane.Visibility = ChartElementVisibility.Hidden;
            }
            return(pane);
        }
        protected virtual Series CreateBarSeries(StrategyDataItemInfo info)
        {
            Series s = new Series();

            s.Name = info.FieldName;
            s.ArgumentDataMember = "Time";
            s.ValueDataMembers.AddRange(info.FieldName);
            s.ValueScaleType = ScaleType.Numerical;
            s.ShowInLegend   = true;
            SideBySideBarSeriesView view = new SideBySideBarSeriesView();

            view.Color    = info.Color;
            view.BarWidth = info.GraphWidth == 1 ? view.BarWidth : (int)(info.GraphWidth * DpiProvider.Default.DpiScaleFactor);
            s.View        = view;
            s.DataSource  = Strategy.StrategyData;
            return(s);
        }
        private Series CreateLineSeries(StrategyDataItemInfo info)
        {
            Series s = new Series();

            s.Name = info.FieldName;
            s.ArgumentDataMember = "Time";
            s.ValueDataMembers.AddRange(info.FieldName);
            s.ValueScaleType = ScaleType.Numerical;
            s.ShowInLegend   = true;
            StepLineSeriesView view = new StepLineSeriesView();

            view.Color = info.Color;
            view.LineStyle.Thickness = (int)(info.GraphWidth * DpiProvider.Default.DpiScaleFactor);
            s.View       = view;
            s.DataSource = Strategy.StrategyData;
            return(s);
        }
Ejemplo n.º 6
0
        protected virtual Series CreateSeries(StrategyDataItemInfo info)
        {
            CheckAddPanel(info);
            Series res = null;

            if (info.ChartType == ChartType.ConstantX || info.ChartType == ChartType.ConstantY)
            {
                CreateConstantLines(info);
                return(null);
            }
            if (info.ChartType == ChartType.CandleStick)
            {
                res = CreateCandleStickSeries(info);
            }
            if (info.ChartType == ChartType.Line || info.ChartType == ChartType.StepLine)
            {
                res = CreateLineSeries(info);
            }
            if (info.ChartType == ChartType.Bar)
            {
                res = CreateBarSeries(info);
            }
            if (info.ChartType == ChartType.Area || info.ChartType == ChartType.StepArea)
            {
                res = CreateAreaSeries(info);
            }
            if (info.ChartType == ChartType.Dot)
            {
                res = CreatePointSeries(info);
            }

            XYDiagramSeriesViewBase view = (XYDiagramSeriesViewBase)res.View;

            if (info.PanelName != "Default")
            {
                view.Pane  = ((XYDiagram)Chart.Diagram).Panes[info.PanelName];
                view.AxisY = ((XYDiagram)Chart.Diagram).SecondaryAxesY[info.AxisYName];
                res.Legend = Chart.Legends[info.PanelName];
            }
            else
            {
            }

            return(res);
        }
        protected virtual void InitializeTickersDataMenu()
        {
            if (Strategy == null)
            {
                return;
            }
            CustomTickerStrategy st = Strategy as CustomTickerStrategy;

            if (st == null)
            {
                return;
            }
            foreach (Ticker t in st.Tickers)
            {
                BarButtonItem bt = new BarButtonItem(this.barManager1, t.Exchange.Name + ": " + t.Name);
                bt.ItemClick += (d, e) => {
                    StrategyDataItemInfo info = new StrategyDataItemInfo();
                    info.DataSource = t.TradeHistory;
                    StrategyDataItemInfo time = StrategyDataItemInfo.TimeItem(info.Children, "Time");
                    time.DataSource   = t.TradeHistory;
                    time.FormatString = "dd.MM hh:mm:ss.fff";
                    StrategyDataItemInfo.DataItem(info.Children, nameof(TradeInfoItem.Rate)).DataSource = t.TradeHistory;
                    StrategyDataItemInfo amount = StrategyDataItemInfo.DataItem(info.Children, nameof(TradeInfoItem.Amount));
                    amount.Visibility = DataVisibility.Table; amount.DataSource = t.TradeHistory;
                    ShowChartForm(info, new StrategyDataVisualiser(info), true);
                };
                this.sbTradeHistory.ItemLinks.Add(bt);

                bt            = new BarButtonItem(this.barManager1, t.Exchange.Name + ": " + t.Name);
                bt.ItemClick += (d, e) => {
                    StrategyDataItemInfo info = new StrategyDataItemInfo();
                    info.DataSource = t.TradeHistory;
                    StrategyDataItemInfo time = StrategyDataItemInfo.TimeItem(info.Children, "Time");
                    time.DataSource   = t.TradeHistory;
                    time.FormatString = "dd.MM hh:mm:ss.fff";
                    StrategyDataItemInfo.DataItem(info.Children, nameof(TradeInfoItem.Rate)).DataSource = t.TradeHistory;
                    StrategyDataItemInfo amount = StrategyDataItemInfo.DataItem(info.Children, nameof(TradeInfoItem.Amount));
                    amount.Visibility = DataVisibility.Table; amount.DataSource = t.TradeHistory;
                    ShowTableForm(info);
                };
                this.sbTradeHistoryTable.ItemLinks.Add(bt);
            }
        }
        protected override void InitializeDataItems()
        {
            base.InitializeDataItems();

            TimeItem("Time");
            DataItem("BaseCurrency").Visibility   = DataVisibility.Table;
            DataItem("MarketCurrency").Visibility = DataVisibility.Table;
            DataItem("LowestAsk").Visibility      = DataVisibility.Table;
            DataItem("HighestBid").Visibility     = DataVisibility.Table;
            DataItem("Spread").Visibility         = DataVisibility.Table;
            DataItem("Profit").Visibility         = DataVisibility.Table;
            DataItem("ProfitUSD").Visibility      = DataVisibility.Table;
            DataItem("Mark").Visibility           = DataVisibility.Table;

            var trend  = DataItem("TrendPreview"); trend.Visibility = DataVisibility.Table;
            var candle = StrategyDataItemInfo.CandleStickItem(trend.Children); candle.Type = DataType.ChartData; candle.Visibility = DataVisibility.Chart; candle.BindingSource = "CandleSticks"; candle.Name = "KLine";

            trend.DetailInfo = candle;
        }
        protected override void InitializeDataItems()
        {
            StrategyDataItemInfo info = TimeItem("Time");

            info.TimeUnit = StrategyDateTimeMeasureUnit.Millisecond;
            info.TimeUnitMeasureMultiplier = 1;
            info.FormatString                = "dd.MM hh:mm:ss.fff";
            DataItem("Index").Visibility     = DataVisibility.Table;
            DataItem("LongAsk").Color        = Exchange.AskColor;
            DataItem("ShortBid").Color       = Exchange.BidColor;
            DataItem("OpenSpread").PanelName = "Spread";
            StrategyDataItemInfo earned = DataItem("Earned");

            earned.FormatString = "0.########";
            earned.PanelName    = "Earned"; earned.Color = Color.FromArgb(0x20, Exchange.BidColor); earned.ChartType = ChartType.Area;
            var mark = AnnotationItem("Mark", null, Color.Green, "MiddleValue"); mark.AnnotationText = "{Mark}"; mark.Type = DataType.ListInString;
            //AnnotationItem("Open", "Open", Exchange.BidColor, "LongAsk");
            //AnnotationItem("Close", "Close", Exchange.AskColor, "ShortBid");
        }
Ejemplo n.º 10
0
        private void OnGridControlDoubleClick(object sender, EventArgs e)
        {
            GridControl grid = (GridControl)sender;
            GridView    view = (GridView)grid.MainView;

            if (view.FocusedRowHandle != GridControl.InvalidRowHandle && view.FocusedColumn != null)
            {
                StrategyDataItemInfo info = (StrategyDataItemInfo)view.FocusedColumn.Tag;
                if (info.DetailInfo != null)
                {
                    info = info.DetailInfo;
                }
                if (info.IsChartData)
                {
                    return;
                }
                info.Value = view.GetFocusedRow();
                ShowChartForm(info);
            }
        }
        protected virtual Series CreateCandleStickSeries(StrategyDataItemInfo info)
        {
            Series s = new Series("Kline", ViewType.CandleStick);

            s.ArgumentDataMember = "Time";
            s.ArgumentScaleType  = ScaleType.DateTime;
            s.ValueDataMembers.AddRange("Low", "High", "Open", "Close");
            s.ValueScaleType = ScaleType.Numerical;
            CandleStickSeriesView view = new CandleStickSeriesView();

            view.LineThickness              = (int)(info.GraphWidth * DpiProvider.Default.DpiScaleFactor);
            view.LevelLineLength            = 0.25;
            view.ReductionOptions.ColorMode = ReductionColorMode.OpenToCloseValue;
            view.ReductionOptions.FillMode  = CandleStickFillMode.FilledOnReduction;
            view.ReductionOptions.Level     = StockLevel.Open;
            view.ReductionOptions.Visible   = true;

            s.View       = view;
            s.DataSource = Strategy.StrategyData;
            return(s);
        }
Ejemplo n.º 12
0
        protected virtual Series CreateBarSeries(StrategyDataItemInfo info)
        {
            Series s = new Series();

            s.Name = info.Name;
            s.ArgumentDataMember = GetArgumentDataMember(info);
            s.ArgumentScaleType  = GetArgumentScaleType(info);
            s.ValueDataMembers.AddRange(info.FieldName);
            s.ValueScaleType = ScaleType.Numerical;
            s.ShowInLegend   = true;
            SideBySideBarSeriesView view = new SideBySideBarSeriesView();

            view.Color    = info.Color;
            view.BarWidth = info.GraphWidth == 1 ? view.BarWidth : (int)(info.GraphWidth * DpiProvider.Default.DpiScaleFactor);
            //view.EqualBarWidth = true;
            view.FillStyle.FillMode = FillMode.Solid;
            view.Border.Visibility  = DefaultBoolean.False;
            s.View       = view;
            s.DataSource = GetDataSource(info);
            return(s);
        }
        private void InitializeDataItems(int intervalSec)
        {
            StrategyDataItemInfo.DataItem(DataItemInfos, "BaseCurrency").Visibility   = DataVisibility.Table;
            StrategyDataItemInfo.DataItem(DataItemInfos, "MarketCurrency").Visibility = DataVisibility.Table;

            StrategyDataItemInfo preview = StrategyDataItemInfo.DataItem(DataItemInfos, "HistogrammPreview"); preview.Color = Color.FromArgb(0x40, Color.Green); preview.Visibility = DataVisibility.Table; preview.MeasureUnit = StrategyDateTimeMeasureUnit.Second; preview.MeasureUnitMultiplier = HistogrammIntervalSec;

            StrategyDataItemInfo candle = StrategyDataItemInfo.CandleStickItem(preview.Children); candle.BindingSource = "Histogramm"; candle.Visibility = DataVisibility.Chart; candle.MeasureUnit = StrategyDateTimeMeasureUnit.Second; candle.MeasureUnitMultiplier = intervalSec;
            StrategyDataItemInfo time   = StrategyDataItemInfo.TimeItem(preview.Children, "Time"); time.BindingSource = "Histogramm"; time.Visibility = DataVisibility.Table;

            StrategyDataItemInfo tcount  = StrategyDataItemInfo.DataItem(preview.Children, "TradeCount"); tcount.BindingSource = "Histogramm"; tcount.Visibility = DataVisibility.Both; tcount.Color = Color.FromArgb(0x80, Color.Green); tcount.ChartType = ChartType.Bar; tcount.MeasureUnit = StrategyDateTimeMeasureUnit.Second; tcount.MeasureUnitMultiplier = intervalSec; tcount.PanelName = "Trades Counts";
            StrategyDataItemInfo tvolume = StrategyDataItemInfo.DataItem(preview.Children, "TradeVolume"); tvolume.BindingSource = "Histogramm"; tvolume.Visibility = DataVisibility.Both; tvolume.Color = Color.FromArgb(0x40, Color.Green); tvolume.ChartType = ChartType.Bar; tvolume.MeasureUnit = StrategyDateTimeMeasureUnit.Second; tvolume.MeasureUnitMultiplier = intervalSec; tvolume.PanelName = "Trades Volumes"; tvolume.PanelVisible = false;

            StrategyDataItemInfo bcount = StrategyDataItemInfo.DataItem(preview.Children, "BuyCount"); bcount.BindingSource = "Histogramm"; bcount.Visibility = DataVisibility.Both; bcount.Color = Color.FromArgb(0x80, Color.Green); bcount.ChartType = ChartType.Bar; bcount.MeasureUnit = StrategyDateTimeMeasureUnit.Second; bcount.MeasureUnitMultiplier = intervalSec; bcount.PanelName = "Buys/Sells Counts";
            StrategyDataItemInfo scount = StrategyDataItemInfo.DataItem(preview.Children, "SellCount"); scount.BindingSource = "Histogramm"; scount.Visibility = DataVisibility.Both; scount.Color = Color.FromArgb(0x80, Color.Red); scount.ChartType = ChartType.Bar; scount.MeasureUnit = StrategyDateTimeMeasureUnit.Second; scount.MeasureUnitMultiplier = intervalSec; scount.PanelName = "Buys/Sells Counts";

            StrategyDataItemInfo bvolume = StrategyDataItemInfo.DataItem(preview.Children, "BuyVolume"); bvolume.BindingSource = "Histogramm"; bvolume.Visibility = DataVisibility.Both; bvolume.Color = Color.FromArgb(0x40, Color.Green); bvolume.ChartType = ChartType.Bar; bvolume.MeasureUnit = StrategyDateTimeMeasureUnit.Second; bvolume.MeasureUnitMultiplier = intervalSec; bvolume.PanelName = "Buys/Sells Volumes"; bvolume.PanelVisible = false;
            StrategyDataItemInfo svolume = StrategyDataItemInfo.DataItem(preview.Children, "SellVolume"); svolume.BindingSource = "Histogramm"; svolume.Visibility = DataVisibility.Both; svolume.Color = Color.FromArgb(0x40, Color.Red); svolume.ChartType = ChartType.Bar; svolume.MeasureUnit = StrategyDateTimeMeasureUnit.Second; svolume.MeasureUnitMultiplier = intervalSec; svolume.PanelName = "Buys/Sells Volumes"; svolume.PanelVisible = false;

            StrategyDataItemInfo dcount  = StrategyDataItemInfo.DataItem(preview.Children, "TrendCount"); dcount.BindingSource = "Histogramm"; dcount.Visibility = DataVisibility.Both; dcount.Color = Color.FromArgb(0x80, Color.Green); dcount.ChartType = ChartType.Line; dcount.MeasureUnit = StrategyDateTimeMeasureUnit.Second; dcount.MeasureUnitMultiplier = intervalSec; dcount.PanelName = "Trend Counts";
            StrategyDataItemInfo dvolume = StrategyDataItemInfo.DataItem(preview.Children, "TrendVolume"); dvolume.BindingSource = "Histogramm"; dvolume.Visibility = DataVisibility.Both; dvolume.Color = Color.FromArgb(0x40, Color.Green); dvolume.ChartType = ChartType.Line; dvolume.MeasureUnit = StrategyDateTimeMeasureUnit.Second; dvolume.MeasureUnitMultiplier = intervalSec; dvolume.PanelName = "Trend Volumes"; dvolume.PanelVisible = false;

            StrategyDataItemInfo tcdr = StrategyDataItemInfo.DataItem(preview.Children, "MaxPriceDeltaInPeriodPc"); tcdr.BindingSource = "Histogramm"; tcdr.Visibility = DataVisibility.Chart; tcdr.Color = Color.FromArgb(0x80, Color.Green); tcdr.ChartType = ChartType.Dot; tcdr.SeparateWindow = true; tcdr.ArgumentDataMember = "TrendCount"; tcdr.ArgumentScaleType = ArgumentScaleType.Numerical; tcdr.ZoomAsMap = true;
        }
 private void OnTreeListDoubleClick(object sender, EventArgs e)
 {
     if (this.tcPosition.FocusedNode != null)
     {
         StrategyDataItemInfo info = (StrategyDataItemInfo)tcPosition.FocusedColumn.Tag;
         if (info.DetailInfo != null)
         {
             info = info.DetailInfo;
         }
         if (!info.IsChartData)
         {
             object item = tcPosition.GetFocusedRow();
             this.chartDataControl1.NavigateTo(item);
             return;
         }
         info.Value       = tcPosition.GetFocusedRow();
         info.BindingRoot = info.Value;
         foreach (var child in info.Children)
         {
             child.BindingRoot = info.Value;
         }
         ShowChartForm(info, new StrategyDataVisualiser(info), true);
     }
 }
        private void CreateAnnotations(StrategyDataItemInfo info)
        {
            if (Strategy.StrategyData.Count == 0)
            {
                return;
            }
            PropertyInfo pInfo   = Strategy.StrategyData[0].GetType().GetProperty(info.FieldName, BindingFlags.Instance | BindingFlags.Public);
            PropertyInfo pAnchor = Strategy.StrategyData[0].GetType().GetProperty(info.AnnotationAnchorField, BindingFlags.Instance | BindingFlags.Public);
            PropertyInfo pTime   = Strategy.StrategyData[0].GetType().GetProperty("Time", BindingFlags.Instance | BindingFlags.Public);

            int index = 0;

            Series s = CreatePointSeries(info);

            s.DataSource = null;
            foreach (object obj in Strategy.StrategyData)
            {
                bool value = (bool)pInfo.GetValue(obj);
                if (!value)
                {
                    index++;
                    continue;
                }
                DateTime    time   = (DateTime)pTime.GetValue(obj);
                double      yValue = (double)pAnchor.GetValue(obj);
                SeriesPoint pt     = new SeriesPoint(time, new double[] { yValue });
                s.Points.Add(pt);

                TextAnnotation annotation = pt.Annotations.AddTextAnnotation(info.FieldName, info.AnnotationText);
                annotation.Text      = info.AnnotationText;
                annotation.ShapeKind = ShapeKind.Rectangle;

                index++;
            }
            Chart.Series.Add(s);
        }
Ejemplo n.º 16
0
        protected virtual void InitializeChart()
        {
            if (Chart == null)
            {
                return;
            }
            bool shouldRemoveDefaultSeries = Chart.Series.Count > 0;
            int  seriesCount = 0;

            for (int i = 0; i < Visual.DataItemInfos.Count; i++)
            {
                StrategyDataItemInfo info = Visual.DataItemInfos[i];
                if (SkipSeparateItems && info.SeparateWindow)
                {
                    continue;
                }
                if (info.Type == DataType.HistogrammData)
                {
                    info = CreateHistogrammDetailItem(info);
                }
                if (!info.Visibility.HasFlag(DataVisibility.Chart))
                {
                    continue;
                }
                if (info.ChartType == ChartType.Annotation)
                {
                    continue;
                }
                Series s = CreateSeries(info);
                if (s == null)
                {
                    continue;
                }
                Chart.Series.Add(s);
                seriesCount++;
            }
            if (seriesCount == 0)
            {
                return;
            }
            if (shouldRemoveDefaultSeries)
            {
                Chart.Series.RemoveAt(0);
            }
            for (int i = 0; i < Visual.DataItemInfos.Count; i++)
            {
                StrategyDataItemInfo info = Visual.DataItemInfos[i];
                if (!info.Visibility.HasFlag(DataVisibility.Chart))
                {
                    continue;
                }
                if (info.ChartType != ChartType.Annotation)
                {
                    continue;
                }
                CreateAnnotations(info);
            }

            CheckInitializeTimeAxis();

            for (int i = 0; i < Visual.DataItemInfos.Count; i++)
            {
                StrategyDataItemInfo info = Visual.DataItemInfos[i];
                if (SkipSeparateItems && info.SeparateWindow)
                {
                    if (info.Type == DataType.HistogrammData)
                    {
                        info = CreateHistogrammDetailItem(info);
                    }
                    if (info.Items == null)
                    {
                        info.Items = Visual.Items;
                    }
                    DataControlProvideEventArgs e = new DataControlProvideEventArgs()
                    {
                        DataItem = info
                    };
                    RaiseGetControl(e);
                }
            }
        }
Ejemplo n.º 17
0
        protected RepositoryItem CreateEditor(object first, StrategyDataItemInfo info)
        {
            if (first == null)
            {
                return(null);
            }
            if (info.FieldName == null)
            {
                return(null);
            }
            PropertyInfo pi = first.GetType().GetProperty(info.FieldName, BindingFlags.Instance | BindingFlags.Public);

            if (pi == null)
            {
                return(null);
            }

            object value = pi.GetValue(first);

            if (pi.PropertyType == typeof(bool) || value is bool)
            {
                RepositoryItemCheckEdit res = new RepositoryItemCheckEdit();
                res.CheckBoxOptions.Style = DevExpress.XtraEditors.Controls.CheckBoxStyle.SvgStar2;
                return(res);
            }
            double[] doubleData = null;
            if (pi.PropertyType == typeof(ResizeableArray <TimeBaseValue>) || value is ResizeableArray <TimeBaseValue> )
            {
                if (value == null)
                {
                    doubleData = new double[0];
                }
                else
                {
                    ResizeableArray <TimeBaseValue> data = (ResizeableArray <TimeBaseValue>)value;
                    doubleData = new double[Math.Min(data.Count, 50)];
                    for (int i = 0; i < doubleData.Length; i++)
                    {
                        doubleData[i] = data[i].Value;
                    }
                }
            }
            if (value is double[] || pi.PropertyType == typeof(double[]))
            {
                if (value == null)
                {
                    doubleData = new double[0];
                }
                else
                {
                    doubleData = (double[])value;
                }
            }
            if (doubleData != null)
            {
                RepositoryItemSparklineEdit res = new RepositoryItemSparklineEdit();
                res.View = new AreaSparklineView()
                {
                    AreaOpacity             = 30,
                    HighlightStartPoint     = false,
                    HighlightEndPoint       = false,
                    HighlightMaxPoint       = false,
                    HighlightMinPoint       = false,
                    HighlightNegativePoints = false
                };
                return(res);
            }
            return(null);
        }
        protected virtual Series CreateSeries(StrategyDataItemInfo info)
        {
            CheckAddPanel(info);
            Series res = null;

            if (info.ChartType == ChartType.ConstantX || info.ChartType == ChartType.ConstantY)
            {
                CreateConstantLines(info);
                return(null);
            }
            if (info.ChartType == ChartType.CandleStick)
            {
                res = CreateCandleStickSeries(info);
            }
            if (info.ChartType == ChartType.Line || info.ChartType == ChartType.StepLine)
            {
                res = CreateLineSeries(info);
            }
            if (info.ChartType == ChartType.Bar)
            {
                res = CreateBarSeries(info);
            }
            if (info.ChartType == ChartType.Area || info.ChartType == ChartType.StepArea)
            {
                res = CreateAreaSeries(info);
            }
            if (info.ChartType == ChartType.Dot)
            {
                res = CreatePointSeries(info);
            }

            if (res != null)
            {
                if (res.Points != null && res.Points.Count > BigDataCount)
                {
                    Chart.SelectionMode     = ElementSelectionMode.None;
                    Chart.RuntimeHitTesting = false;
                }
                res.DataSourceSorted    = true;
                res.SeriesPointsSorting = SortingMode.None;
            }
            IResizeableArray array = res.DataSource as IResizeableArray;

            if (array != null && array.Count > BigDataCount)  // optimization
            {
                PointSeriesView view2 = res.View as PointSeriesView;
                if (view2 != null)
                {
                    view2.AggregateFunction = SeriesAggregateFunction.None;
                }
            }
            XYDiagramSeriesViewBase view = (XYDiagramSeriesViewBase)res.View;

            if (info.PanelName != "Default")
            {
                view.Pane  = ((XYDiagram)Chart.Diagram).Panes[info.PanelName];
                view.AxisY = ((XYDiagram)Chart.Diagram).SecondaryAxesY[info.AxisYName];
                if (((XYDiagram)Chart.Diagram).SecondaryAxesX[info.AxisXName] != null)
                {
                    view.AxisX = ((XYDiagram)Chart.Diagram).SecondaryAxesX[info.AxisXName];
                }
                res.Legend = Chart.Legends[info.PanelName];
            }
            else
            {
            }

            return(res);
        }
Ejemplo n.º 19
0
        private void CheckInitializeTimeAxis()
        {
            int      totalMinutes = Visual.MeasureUnitMultiplier;
            DateTime first        = DateTime.MinValue;
            DateTime last         = DateTime.MaxValue;

            ((XYDiagram)Chart.Diagram).AxisX.DateTimeScaleOptions.MeasureUnit = (DateTimeMeasureUnit)Enum.Parse(typeof(DateTimeMeasureUnit), Visual.MeasureUnit.ToString());
            if (Visual.Items != null && Visual.Items.Count > 1)
            {
                object       data1    = Visual.Items[1];
                object       data0    = Visual.Items[0];
                object       dataLast = Visual.Items.Last();
                PropertyInfo pi       = data1.GetType().GetProperty("Time", BindingFlags.Public | BindingFlags.Instance);
                if (pi != null)
                {
                    DateTime time1 = (DateTime)pi.GetValue(data1);
                    DateTime time0 = (DateTime)pi.GetValue(data0);
                    first        = time1;
                    last         = (DateTime)pi.GetValue(dataLast);
                    totalMinutes = (int)((time1 - time0).TotalMinutes);
                }
            }

            StrategyDataItemInfo di = Visual.DataItemInfos.FirstOrDefault(i => i.Type == DataType.DateTime && i.FieldName == "Time");

            if (di != null)
            {
                if (di.UseCustomTimeUnit)
                {
                    ((XYDiagram)Chart.Diagram).AxisX.DateTimeScaleOptions.MeasureUnit           = (DateTimeMeasureUnit)Enum.Parse(typeof(DateTimeMeasureUnit), di.TimeUnit.ToString());
                    ((XYDiagram)Chart.Diagram).AxisX.DateTimeScaleOptions.MeasureUnitMultiplier = di.TimeUnitMeasureMultiplier;
                }
            }

            ((XYDiagram)Chart.Diagram).AxisX.DateTimeScaleOptions.MeasureUnitMultiplier   = totalMinutes;
            ((XYDiagram)Chart.Diagram).AxisX.Label.ResolveOverlappingOptions.AllowRotate  = false;
            ((XYDiagram)Chart.Diagram).AxisX.Label.ResolveOverlappingOptions.AllowStagger = false;

            ((XYDiagram)Chart.Diagram).AxisX.LabelVisibilityMode = AxisLabelVisibilityMode.AutoGeneratedAndCustom;
            if (first != DateTime.MinValue)
            {
                DateTime current = first.Date;
                while (current <= last)
                {
                    ConstantLine constantLine = new ConstantLine(current.ToShortDateString(), current)
                    {
                        Color = Color.FromArgb(0x40, Color.LightGray), ShowInLegend = false
                    };
                    constantLine.Title.Visible = false;
                    ((XYDiagram)Chart.Diagram).AxisX.ConstantLines.Add(constantLine);
                    ((XYDiagram)Chart.Diagram).AxisX.CustomLabels.Add(new CustomAxisLabel(current.ToShortDateString(), current));
                    current = current.AddDays(1);
                }
            }

            StrategyDataItemInfo time = Visual.DataItemInfos.FirstOrDefault(i => i.Name == "Time");
            string datePattern        = "{A:dd.MM hh:mm:ss}";

            if (time != null && !string.IsNullOrEmpty(time.LabelPattern))
            {
                datePattern = "{A:" + time.LabelPattern + "}";
            }

            if (Chart.Series[0].ArgumentScaleType == ScaleType.Numerical)
            {
                ((XYDiagram)Chart.Diagram).AxisX.Label.TextPattern = "{A}";
            }
            else
            {
                ((XYDiagram)Chart.Diagram).AxisX.Label.TextPattern = datePattern;
            }
        }
Ejemplo n.º 20
0
 protected string GetArgumentDataMember(StrategyDataItemInfo info)
 {
     return(string.IsNullOrEmpty(info.ArgumentDataMember) ? "Time" : info.ArgumentDataMember);
 }
        protected virtual Series CreateCandleStickSeries(StrategyDataItemInfo info)
        {
            Series s = new Series("Kline", ViewType.CandleStick);

            s.ArgumentDataMember = "Time";
            s.ArgumentScaleType  = ScaleType.DateTime;
            s.ValueDataMembers.AddRange("Low", "High", "Open", "Close");
            s.ValueScaleType = ScaleType.Numerical;

            CandleStickSeriesView view = new CandleStickSeriesView();

            view.LineThickness              = (int)(info.GraphWidth * DpiProvider.Default.DpiScaleFactor);
            view.LevelLineLength            = 0.25;
            view.ReductionOptions.ColorMode = ReductionColorMode.OpenToCloseValue;
            view.ReductionOptions.FillMode  = CandleStickFillMode.AlwaysFilled;
            view.Color = DXSkinColors.ForeColors.Information;
            view.ReductionOptions.Color = DXSkinColors.ForeColors.Critical;

            view.ReductionOptions.Level   = StockLevel.Open;
            view.ReductionOptions.Visible = true;
            view.AggregateFunction        = SeriesAggregateFunction.Financial;
            view.LineThickness            = (int)(1 * DpiProvider.Default.DpiScaleFactor);
            view.LevelLineLength          = 0.25;

            s.View = view;
            s.CrosshairLabelPattern = "O={OV}\nH={HV}\nL={LV}\nC={CV}";

            object           dataSource = GetDataSource(info);
            IResizeableArray array      = dataSource as IResizeableArray;

            if (array == null || array.Count < BigDataCount)
            {
                s.DataSource = dataSource;
            }
            else
            {
                SeriesPoint[] points = new SeriesPoint[array.Count];
                PropertyInfo  ap     = array.GetItem(0).GetType().GetProperty(s.ArgumentDataMember, BindingFlags.Public | BindingFlags.Instance);
                PropertyInfo  lp     = array.GetItem(0).GetType().GetProperty("Low", BindingFlags.Public | BindingFlags.Instance);
                PropertyInfo  hp     = array.GetItem(0).GetType().GetProperty("High", BindingFlags.Public | BindingFlags.Instance);
                PropertyInfo  op     = array.GetItem(0).GetType().GetProperty("Open", BindingFlags.Public | BindingFlags.Instance);
                PropertyInfo  cp     = array.GetItem(0).GetType().GetProperty("Close", BindingFlags.Public | BindingFlags.Instance);

                Func <object, object> af = MakeAccessor(array.GetItem(0).GetType(), ap.PropertyType, s.ArgumentDataMember);
                Func <object, object> lf = MakeAccessor(array.GetItem(0).GetType(), lp.PropertyType, "Low");
                Func <object, object> hf = MakeAccessor(array.GetItem(0).GetType(), lp.PropertyType, "High");
                Func <object, object> of = MakeAccessor(array.GetItem(0).GetType(), lp.PropertyType, "Open");
                Func <object, object> cf = MakeAccessor(array.GetItem(0).GetType(), lp.PropertyType, "Close");

                if (ap.PropertyType == typeof(DateTime))
                {
                    for (int i = 0; i < array.Count; i++)
                    {
                        object item = array.GetItem(i);
                        points[i] = new SeriesPoint((DateTime)af(item),
                                                    new double[] {
                            (double)lf(item),
                            (double)hf(item),
                            (double)of(item),
                            (double)cf(item)
                        });
                    }
                }
                s.Points.AddRange(points);
            }

            //s.DataSource = GetDataSource(info);
            return(s);
        }
Ejemplo n.º 22
0
        private void CreateAnnotations(StrategyDataItemInfo info)
        {
            if (Visual.Items.Count == 0)
            {
                return;
            }
            PropertyInfo      pInfo   = Visual.Items[0].GetType().GetProperty(info.FieldName, BindingFlags.Instance | BindingFlags.Public);
            PropertyInfo      pAnchor = Visual.Items[0].GetType().GetProperty(info.AnnotationAnchorField, BindingFlags.Instance | BindingFlags.Public);
            PropertyInfo      pTime   = Visual.Items[0].GetType().GetProperty("Time", BindingFlags.Instance | BindingFlags.Public);
            XYDiagramPaneBase pane    = ((XYDiagram)Chart.Diagram).DefaultPane;

            if (info.PanelName != "Default")
            {
                pane = ((XYDiagram)Chart.Diagram).Panes[info.PanelName];
            }

            int index = 0;

            ResizeableArray <TextAnnotation> res = new ResizeableArray <TextAnnotation>();

            info.DataSource = res;
            for (int i = 0; i < Visual.Items.Count; i++)
            {
                object obj   = Visual.Items[i];
                object value = pInfo.GetValue(obj);
                if (value == null)
                {
                    index++;
                    continue;
                }
                if (value is bool && !((bool)value))
                {
                    index++;
                    continue;
                }
                DateTime time           = (DateTime)pTime.GetValue(obj);
                double   yValue         = (double)pAnchor.GetValue(obj);
                string   annotationText = string.Empty;
                if (info.HasAnnotationStringFormat)
                {
                    annotationText = GetFormattedText(info.AnnotationText, obj);
                }
                else
                {
                    annotationText = Convert.ToString(value);
                }

                TextAnnotation annotation = pane.Annotations.AddTextAnnotation(info.FieldName + "InPane" + info.PanelName, annotationText);
                res.Add(annotation);
                annotation.Tag            = obj;
                annotation.ConnectorStyle = AnnotationConnectorStyle.Line;
                annotation.ShapeKind      = ShapeKind.Rectangle;
                annotation.Font           = new Font("Segoe UI", 6);
                ((RelativePosition)annotation.ShapePosition).Angle           = 180;
                ((RelativePosition)annotation.ShapePosition).ConnectorLength = 70;

                PaneAnchorPoint point = new PaneAnchorPoint();
                point.AxisXCoordinate.AxisValue = time;
                point.AxisYCoordinate.AxisValue = yValue;
                point.Pane             = pane;
                annotation.AnchorPoint = point;
                annotation.ShapeKind   = ShapeKind.Rectangle;
                annotation.ShapeKind   = ShapeKind.Rectangle;
                index++;
            }
        }
        protected virtual void InitializeChart()
        {
            if (Chart == null)
            {
                return;
            }
            Chart.CacheToMemory = true;
            bool shouldRemoveDefaultSeries = Chart.Series.Count > 0;
            int  seriesCount = 0;

            for (int i = 0; i < Visual.DataItemInfos.Count; i++)
            {
                StrategyDataItemInfo info = Visual.DataItemInfos[i];
                if (SkipSeparateItems && info.SeparateWindow)
                {
                    continue;
                }
                if (info.ZoomAsMap)
                {
                    ((XYDiagram)Chart.Diagram).EnableAxisYScrolling = true;
                    ((XYDiagram)Chart.Diagram).EnableAxisYZooming   = true;
                    ((XYDiagram)Chart.Diagram).DependentAxesYRange  = DefaultBoolean.False;
                }
                if (info.Type == DataType.HistogrammData)
                {
                    info = CreateHistogrammDetailItem(info);
                }
                if (!info.Visibility.HasFlag(DataVisibility.Chart))
                {
                    continue;
                }
                if (info.ChartType == ChartType.Annotation)
                {
                    continue;
                }
                Series s = CreateSeries(info);
                if (s == null)
                {
                    continue;
                }
                if (!Chart.Series.Contains(s))
                {
                    Chart.Series.Add(s);
                }
                OnAfterAddSeries(s);
                seriesCount++;
            }
            if (seriesCount == 0)
            {
                return;
            }
            if (shouldRemoveDefaultSeries)
            {
                Chart.Series.RemoveAt(0);
            }
            for (int i = 0; i < Visual.DataItemInfos.Count; i++)
            {
                StrategyDataItemInfo info = Visual.DataItemInfos[i];
                if (!info.Visibility.HasFlag(DataVisibility.Chart))
                {
                    continue;
                }
                if (info.ChartType != ChartType.Annotation)
                {
                    continue;
                }
                CreateAnnotations(info);
            }

            CheckInitializeTimeAxis();

            for (int i = 0; i < Visual.DataItemInfos.Count; i++)
            {
                StrategyDataItemInfo info = Visual.DataItemInfos[i];
                if (info == Visual)
                {
                    continue;
                }
                if (info.SeparateWindow)
                {
                    if (info.Type == DataType.HistogrammData)
                    {
                        info = CreateHistogrammDetailItem(info);
                    }
                    if (info.Items == null)
                    {
                        info.Items = Visual.Items;
                    }
                    DataControlProvideEventArgs e = new DataControlProvideEventArgs()
                    {
                        DataItem = info
                    };
                    RaiseGetControl(e);
                }
            }
        }
Ejemplo n.º 24
0
        protected virtual void CreateConstantLines(StrategyDataItemInfo info)
        {
            XYDiagram         dg   = (XYDiagram)Chart.Diagram;
            XYDiagramPaneBase pane = CheckAddPanel(info);
            Axis axis = null;

            if (info.PanelName == "Default")
            {
                axis = info.ChartType == ChartType.ConstantX? (Axis)dg.AxisX: (Axis)dg.AxisY;
            }
            else
            {
                if (info.ChartType == ChartType.ConstantX)
                {
                    axis = dg.SecondaryAxesX[info.PanelName];
                }
                else
                {
                    axis = dg.SecondaryAxesY[info.PanelName];
                }
            }
            if (axis == null)
            {
                return;
            }

            if (axis != null)
            {
                System.Collections.IEnumerable en = info.DataSource as System.Collections.IEnumerable;
                if (en != null)
                {
                    PropertyInfo pi = null;
                    foreach (object item in en)
                    {
                        if (pi == null)
                        {
                            pi = item.GetType().GetProperty(info.FieldName, BindingFlags.Instance | BindingFlags.Public);
                        }
                        double value = Convert.ToDouble(pi.GetValue(item));
                        axis.ConstantLines.Add(new ConstantLine()
                        {
                            AxisValue = value, Color = info.Color, Name = item.ToString(), ShowInLegend = false
                        });
                    }
                }
                else
                {
                    object value = info.DataSource == null ? info.Value : info.DataSource;
                    if (value != null)
                    {
                        axis.ConstantLines.Add(new ConstantLine()
                        {
                            AxisValue = value, Color = info.Color, Name = info.Name, ShowInLegend = false
                        });
                    }
                }
                if (info.ChartType == ChartType.ConstantY)
                {
                    this.Chart.AxisWholeRangeChanged -= OnYAxisWholeRangeChanged;
                    this.Chart.AxisWholeRangeChanged += OnYAxisWholeRangeChanged;
                }
            }
        }
Ejemplo n.º 25
0
 private StrategyDataItemInfo CreateHistogrammDetailItem(StrategyDataItemInfo info)
 {
     return(info.CreateHistogrammDetailItem(Visual));
 }