void IndicatorSource2_SelectionChanged(object sender, SelectionChangedEventArgs e) { indicatorsCollection.Clear(); this.ChartArea.TechnicalIndicators.Clear(); foreach (var indi in IndicatorSource2.SelectedItems) { var indicator = Addindicator((string)indi, 1); if (indicator != null) { indicatorsCollection.Add(indicator); } } foreach (var item in indicatorsCollection) { ISupportAxes2D indicatorAxis = item as ISupportAxes2D; var index = SfChart.GetRow(indicatorAxis.YAxis); if (index == 0) { this.ChartArea.TechnicalIndicators.Add(item); NumericalAxis axis = new NumericalAxis(); axis.OpposedPosition = true; axis.ShowGridLines = false; axis.Visibility = Visibility.Collapsed; indicatorAxis.YAxis = axis; SfChart.SetRow(indicatorAxis.YAxis, 0); } } }
private FinancialTechnicalIndicator Addindicator(string value, int rowIndex) { FinancialTechnicalIndicator indic; switch (value) { case "AccumulationDistributionIndicator": indic = new AccumulationDistributionIndicator(); break; case "AverageTrueRangeIndicator": indic = new AverageTrueRangeIndicator(); break; case "BollingerBandIndicator": indic = new BollingerBandIndicator(); break; case "ExponentialAverageIndicator": indic = new ExponentialAverageIndicator(); break; case "MACDTechnicalIndicator": indic = new MACDTechnicalIndicator(); break; case "MomentumTechnicalIndicator": indic = new MomentumTechnicalIndicator(); break; case "RSITechnicalIndicator": indic = new RSITechnicalIndicator(); break; case "SimpleAverageIndicator": indic = new SimpleAverageIndicator(); break; case "StochasticTechnicalIndicator": indic = new StochasticTechnicalIndicator(); break; case "TriangularAverageIndicator": indic = new TriangularAverageIndicator(); break; default: return(null); } var index = rowIndex == 0 ? 1 : 0; ChartSeries Series = this.ChartArea.VisibleSeries[index] as ChartSeries; indic.XBindingPath = "TimeStamp"; indic.High = "High"; indic.Low = "Low"; indic.Open = "Open"; indic.Close = "Last"; indic.Volume = "Volume"; Binding binding = new Binding(); binding.Path = new PropertyPath("ItemsSource"); binding.Source = Series; binding.Mode = BindingMode.TwoWay; indic.SetBinding(FinancialTechnicalIndicator.ItemsSourceProperty, binding); if (rowIndex == 0) { var supportAxes = this.ChartArea.VisibleSeries[1] as ISupportAxes; if (supportAxes != null) { indic.YAxis = supportAxes.ActualYAxis as RangeAxisBase; } indic.YAxis.ShowGridLines = false; SfChart.SetRow(indic.YAxis, 1); } else { indic.YAxis = this.ChartArea.SecondaryAxis; SfChart.SetRow(indic.YAxis, 0); } return(indic); }