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); }
private FinancialTechnicalIndicator Addindicator(string value, int rowIndex) { FinancialTechnicalIndicator indicator; string a = ""; object obj = a; string b = (obj as string); switch (value) { case "Accumulation Distribution": StockViewModel model = new StockViewModel(1); DataContext = model.Stocks; indicator = new AccumulationDistributionIndicator() { SignalLineColor = new SolidColorBrush(Colors.Blue) }; SfChart.Annotations.Clear(); LineAnnotation annotationAD = new LineAnnotation { FontSize = 15, Text = "High in Prices", HorizontalTextAlignment = HorizontalAlignment.Center, VerticalTextAlignment = VerticalAlignment.Top, CoordinateUnit = CoordinateUnit.Axis, X1 = 22, Y1 = 30, X2 = 26, Y2 = 40 }; LineAnnotation annotation2AD = new LineAnnotation { FontSize = 15, Text = "Decline in Prices", CoordinateUnit = CoordinateUnit.Axis, X1 = 38, Y1 = 28, X2 = 46, Y2 = 15 }; LineAnnotation annotation3AD = new LineAnnotation { FontSize = 15, Text = "Price is Trending Down", CoordinateUnit = CoordinateUnit.Axis, X1 = 0.1, Y1 = 41.5, X2 = 14, Y2 = 13 }; SfChart.Annotations.Add(annotationAD); SfChart.Annotations.Add(annotation2AD); SfChart.Annotations.Add(annotation3AD); break; case "Average True Range": StockViewModel model9 = new StockViewModel(1); DataContext = model9.Stocks; SfChart.Annotations.Clear(); indicator = new AverageTrueRangeIndicator() { SignalLineColor = new SolidColorBrush(Colors.Blue), Period = 2 }; TextAnnotation annotationAT = new TextAnnotation { Text = "Buy Signal", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 6, Y1 = 37 }; TextAnnotation annotationAT1 = new TextAnnotation { Text = "Buy Signal", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 8, Y1 = 18 }; TextAnnotation annotationAT2 = new TextAnnotation { Text = "Sell Signal", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 20, Y1 = 24 }; TextAnnotation annotationAT3 = new TextAnnotation { Text = "Sell Signal", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 27.3, Y1 = 41 }; TextAnnotation annotationAT4 = new TextAnnotation { Text = "Average True Range" + "\n" + "Trailing Stops", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 35, Y1 = 22 }; SfChart.Annotations.Add(annotationAT); SfChart.Annotations.Add(annotationAT1); SfChart.Annotations.Add(annotationAT2); SfChart.Annotations.Add(annotationAT3); SfChart.Annotations.Add(annotationAT4); break; case "Bollinger Band": StockViewModel model1 = new StockViewModel(0); DataContext = model1.Stocks; indicator = new BollingerBandIndicator() { UpperLineColor = new SolidColorBrush(Colors.Green), LowerLineColor = new SolidColorBrush(Colors.Red), SignalLineColor = new SolidColorBrush(Colors.Transparent), Period = 2 }; SfChart.Annotations.Clear(); TextAnnotation annotation = new TextAnnotation { Text = "Upper Bollinger Band", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 6, Y1 = 650 }; TextAnnotation annotation1 = new TextAnnotation { Text = "Sell Signal", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 33.7, Y1 = 660 }; TextAnnotation annotation2 = new TextAnnotation { Text = "Lower Bollinger Band", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 40, Y1 = 390 }; TextAnnotation annotation3 = new TextAnnotation { Text = "Buy Signal", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 7, Y1 = 230 }; SfChart.Annotations.Add(annotation); SfChart.Annotations.Add(annotation1); SfChart.Annotations.Add(annotation2); SfChart.Annotations.Add(annotation3); break; case "Exponential Average": StockViewModel model8 = new StockViewModel(0); DataContext = model8.Stocks; indicator = new ExponentialAverageIndicator() { SignalLineColor = new SolidColorBrush(Colors.Blue) }; SfChart.Annotations.Clear(); TextAnnotation annotationE = new TextAnnotation { Text = "BUY", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 0.3, Y1 = 700 }; TextAnnotation annotationE1 = new TextAnnotation { Text = "SELL", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 2, Y1 = 605 }; TextAnnotation annotationE2 = new TextAnnotation { Text = "BUY", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 8, Y1 = 260 }; TextAnnotation annotationE3 = new TextAnnotation { Text = "SELL", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 20, Y1 = 580 }; TextAnnotation annotationE4 = new TextAnnotation { Text = "BUY", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 26, Y1 = 450 }; TextAnnotation annotationE5 = new TextAnnotation { Text = "SELL", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 35, Y1 = 660 }; TextAnnotation annotationE6 = new TextAnnotation { Text = "BUY", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 40, Y1 = 460 }; TextAnnotation annotationE7 = new TextAnnotation { Text = "SELL", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 54, Y1 = 760 }; SfChart.Annotations.Add(annotationE); SfChart.Annotations.Add(annotationE1); SfChart.Annotations.Add(annotationE2); SfChart.Annotations.Add(annotationE3); SfChart.Annotations.Add(annotationE4); SfChart.Annotations.Add(annotationE5); SfChart.Annotations.Add(annotationE6); SfChart.Annotations.Add(annotationE7); break; case "MACD": StockViewModel model7 = new StockViewModel(2); DataContext = model7.Stocks; SfChart.Annotations.Clear(); indicator = new MACDTechnicalIndicator() { Period = 5, LongPeriod = 8, ShortPeriod = 3, SignalLineColor = new SolidColorBrush(Colors.Blue), ConvergenceLineColor = new SolidColorBrush(Colors.Green), DivergenceLineColor = new SolidColorBrush(Colors.Red) }; TextAnnotation annotationMA = new TextAnnotation { Text = "MACD" + "\n" + "Sell Signals", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 17, Y1 = 700 }; TextAnnotation annotationMA1 = new TextAnnotation { Text = "MACD" + "\n" + "Buy Signals", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 2, Y1 = 400 }; TextAnnotation annotationMA2 = new TextAnnotation { Text = "Buy", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 10, Y1 = 250 }; TextAnnotation annotationMA3 = new TextAnnotation { Text = "Sell", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 24, Y1 = 620 }; TextAnnotation annotationMA4 = new TextAnnotation { Text = "Buy", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 30, Y1 = 450 }; TextAnnotation annotationMA5 = new TextAnnotation { Text = "Sell", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 48, Y1 = 650 }; SfChart.Annotations.Add(annotationMA); SfChart.Annotations.Add(annotationMA1); SfChart.Annotations.Add(annotationMA2); SfChart.Annotations.Add(annotationMA3); SfChart.Annotations.Add(annotationMA4); SfChart.Annotations.Add(annotationMA5); break; case "Momentum": SfChart.Annotations.Clear(); StockViewModel model6 = new StockViewModel(2); DataContext = model6.Stocks; indicator = new MomentumTechnicalIndicator() { MomentumLineColor = new SolidColorBrush(Colors.Blue), Period = 4 }; LineAnnotation annotationM = new LineAnnotation { Text = "Downtrend", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 2, Y1 = 463, X2 = 12, Y2 = 245 }; TextAnnotation annotationM1 = new TextAnnotation { Text = "Buy", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 8, Y1 = 450 }; TextAnnotation annotationM2 = new TextAnnotation { Text = "Sell", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 21, Y1 = 530 }; LineAnnotation annotationM3 = new LineAnnotation { Text = "Divergence of Price" + "\n" + "& Momentum", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 36.5, Y1 = 468, X2 = 47.5, Y2 = 394 }; SfChart.Annotations.Add(annotationM); SfChart.Annotations.Add(annotationM1); SfChart.Annotations.Add(annotationM2); SfChart.Annotations.Add(annotationM3); break; case "RSI": StockViewModel model5 = new StockViewModel(2); DataContext = model5.Stocks; SfChart.Annotations.Clear(); indicator = new RSITechnicalIndicator() { SignalLineColor = new SolidColorBrush(Colors.Blue), LowerLineColor = new SolidColorBrush(Colors.Red), Period = 5, UpperLineColor = new SolidColorBrush(Colors.Green) }; TextAnnotation annotationRS = new TextAnnotation { Text = "Oversold", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 42, Y1 = 645 }; TextAnnotation annotationRS1 = new TextAnnotation { Text = "Overbought", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 0.3, Y1 = 380 }; TextAnnotation annotationRS2 = new TextAnnotation { Text = "Seller Territory" + "\n" + "(over 500)", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 10, Y1 = 600 }; TextAnnotation annotationRS3 = new TextAnnotation { Text = "Buyers Territory" + "\n" + "(below 500)", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 50, Y1 = 450 }; SfChart.Annotations.Add(annotationRS); SfChart.Annotations.Add(annotationRS1); SfChart.Annotations.Add(annotationRS2); SfChart.Annotations.Add(annotationRS3); break; case "Simple Average": StockViewModel model4 = new StockViewModel(0); DataContext = model4.Stocks; SfChart.Annotations.Clear(); indicator = new SimpleAverageIndicator() { SignalLineColor = new SolidColorBrush(Colors.Blue) }; TextAnnotation annotationSA = new TextAnnotation { Text = "BUY", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 0, Y1 = 405 }; TextAnnotation annotationSA1 = new TextAnnotation { Text = "BUY", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 8, Y1 = 250 }; TextAnnotation annotationSA2 = new TextAnnotation { Text = "SELL", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 21, Y1 = 620 }; TextAnnotation annotationSA3 = new TextAnnotation { Text = "SELL", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 31, Y1 = 630 }; TextAnnotation annotationSA6 = new TextAnnotation { Text = "BUY", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 40, Y1 = 475 }; TextAnnotation annotationSA7 = new TextAnnotation { Text = "SELL", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 54, Y1 = 760 }; SfChart.Annotations.Add(annotationSA); SfChart.Annotations.Add(annotationSA1); SfChart.Annotations.Add(annotationSA2); SfChart.Annotations.Add(annotationSA3); SfChart.Annotations.Add(annotationSA6); SfChart.Annotations.Add(annotationSA7); break; case "Stochastic": SfChart.Annotations.Clear(); StockViewModel model3 = new StockViewModel(0); DataContext = model3.Stocks; indicator = new StochasticTechnicalIndicator() { SignalLineColor = new SolidColorBrush(Colors.Red), UpperLineColor = new SolidColorBrush(Colors.Green), Period = 3 }; LineAnnotation annotationS = new LineAnnotation { Text = "Lower Low", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 0.8, Y1 = 433, X2 = 9.4, Y2 = 243 }; TextAnnotation annotationS1 = new TextAnnotation { Text = "Low#1", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = -0.6, Y1 = 420 }; TextAnnotation annotationS2 = new TextAnnotation { Text = "Low#2", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 8, Y1 = 243 }; LineAnnotation annotationS4 = new LineAnnotation { Text = "Higher High", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 11.5, Y1 = 369, X2 = 22.5, Y2 = 632 }; TextAnnotation annotationS5 = new TextAnnotation { Text = "High#2", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 21, Y1 = 650 }; TextAnnotation annotationS6 = new TextAnnotation { Text = "High#1", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 10, Y1 = 370 }; LineAnnotation annotationS7 = new LineAnnotation { Text = "Higher Low", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 38, Y1 = 637, X2 = 48, Y2 = 680 }; TextAnnotation annotationS8 = new TextAnnotation { Text = "Low#3", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 37, Y1 = 670 }; TextAnnotation annotationS9 = new TextAnnotation { Text = "Low#4", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 48, Y1 = 700 }; SfChart.Annotations.Add(annotationS); SfChart.Annotations.Add(annotationS1); SfChart.Annotations.Add(annotationS2); SfChart.Annotations.Add(annotationS4); SfChart.Annotations.Add(annotationS5); SfChart.Annotations.Add(annotationS6); SfChart.Annotations.Add(annotationS7); SfChart.Annotations.Add(annotationS8); SfChart.Annotations.Add(annotationS9); break; case "Triangular Average": StockViewModel model2 = new StockViewModel(0); DataContext = model2.Stocks; SfChart.Annotations.Clear(); indicator = new TriangularAverageIndicator() { SignalLineColor = new SolidColorBrush(Colors.Blue) }; TextAnnotation annotationT = new TextAnnotation { Text = "BUY", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 2, Y1 = 400 }; TextAnnotation annotationT1 = new TextAnnotation { Text = "BUY", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 8, Y1 = 250 }; TextAnnotation annotationT2 = new TextAnnotation { Text = "SELL", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 21, Y1 = 620 }; TextAnnotation annotationT3 = new TextAnnotation { Text = "SELL", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 31, Y1 = 630 }; TextAnnotation annotationT6 = new TextAnnotation { Text = "BUY", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 40, Y1 = 475 }; TextAnnotation annotationT7 = new TextAnnotation { Text = "SELL", FontSize = 15, CoordinateUnit = CoordinateUnit.Axis, X1 = 54, Y1 = 760 }; SfChart.Annotations.Add(annotationT); SfChart.Annotations.Add(annotationT1); SfChart.Annotations.Add(annotationT2); SfChart.Annotations.Add(annotationT3); SfChart.Annotations.Add(annotationT6); SfChart.Annotations.Add(annotationT7); break; default: return(null); } var index = rowIndex == 0 ? 1 : 0; ChartSeries Series = this.SfChart.VisibleSeries[index] as ChartSeries; indicator.XBindingPath = "TimeStamp"; indicator.High = "High"; indicator.Low = "Low"; indicator.Open = "Open"; indicator.Close = "Last"; indicator.Volume = "Volume"; Binding binding = new Binding(); binding.Path = new PropertyPath("ItemsSource"); binding.Source = Series; binding.Mode = BindingMode.TwoWay; indicator.SetBinding(FinancialTechnicalIndicator.ItemsSourceProperty, binding); return(indicator); }
private FinancialTechnicalIndicator Addindicator(string value) { FinancialTechnicalIndicator indicator; switch (value) { case "Accumulation Distribution": indicator = new AccumulationDistributionIndicator(); break; case "Average True Range": indicator = new AverageTrueRangeIndicator() { Period = 1 }; break; case "Bollinger Band": indicator = new BollingerBandIndicator() { UpperLineColor = Brushes.Green, Period = 3 }; break; case "Exponential Average": indicator = new ExponentialAverageIndicator(); break; case "MACD": indicator = new MACDTechnicalIndicator() { Period = 5, LongPeriod = 12, ShortPeriod = 6, ConvergenceLineColor = Brushes.Green }; break; case "Momentum": indicator = new MomentumTechnicalIndicator() { Period = 4 }; break; case "RSI": indicator = new RSITechnicalIndicator() { Period = 4, UpperLineColor = Brushes.Green }; break; case "Simple Average": indicator = new SimpleAverageIndicator(); break; case "Stochastic": indicator = new StochasticTechnicalIndicator() { UpperLineColor = Brushes.Green }; break; case "Triangular Average": indicator = new TriangularAverageIndicator(); break; default: return(null); } indicator.XBindingPath = "TimeStamp"; indicator.High = "High"; indicator.Low = "Low"; indicator.Open = "Open"; indicator.Close = "Last"; indicator.Volume = "Volume"; Binding binding = new Binding(); binding.Path = new PropertyPath("Datas"); binding.Source = this; binding.Mode = BindingMode.TwoWay; indicator.SetBinding(FinancialTechnicalIndicator.ItemsSourceProperty, binding); ISupportAxes2D indicatorAxis = indicator as ISupportAxes2D; if (indicatorAxis != null) { NumericalAxis axis = new NumericalAxis(); axis.OpposedPosition = true; axis.ShowGridLines = false; axis.Visibility = Visibility.Collapsed; indicatorAxis.YAxis = axis; } return(indicator); }
void ChartView_PropertyChanged(object sender, PropertyChangedEventArgs e) { switch (selectedIndicator) { case "Accumulation Distribution": { HiLoOpenCloseSeries series = StockChart.Series[0] as HiLoOpenCloseSeries; ColumnSeries series1 = StockChart.Series[1] as ColumnSeries; AccumulationDistributionIndicator indicator = new AccumulationDistributionIndicator(); NumericalAxis axis1 = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; indicator.YAxis = axis1; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; if (StockChart.TechnicalIndicators.Count > 0) { StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); } StockChart.TechnicalIndicators.Add(indicator); indicator = new AccumulationDistributionIndicator(); NumericalAxis axis = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; UI.Xaml.Charts.SfChart.SetRow(axis, 1); indicator.YAxis = axis; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; StockChart.TechnicalIndicators.Add(indicator); } break; case "Average True Range": { HiLoOpenCloseSeries series = StockChart.Series[0] as HiLoOpenCloseSeries; ColumnSeries series1 = StockChart.Series[1] as ColumnSeries; AverageTrueRangeIndicator indicator = new AverageTrueRangeIndicator(); NumericalAxis axis1 = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; indicator.YAxis = axis1; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; if (StockChart.TechnicalIndicators.Count > 0) { StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); } StockChart.TechnicalIndicators.Add(indicator); indicator = new AverageTrueRangeIndicator(); NumericalAxis axis = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; UI.Xaml.Charts.SfChart.SetRow(axis, 1); indicator.YAxis = axis; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; StockChart.TechnicalIndicators.Add(indicator); } break; case "BollingerBand": { HiLoOpenCloseSeries series = StockChart.Series[0] as HiLoOpenCloseSeries; ColumnSeries series1 = StockChart.Series[1] as ColumnSeries; BollingerBandIndicator indicator = new BollingerBandIndicator(); NumericalAxis axis1 = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; indicator.YAxis = axis1; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; if (StockChart.TechnicalIndicators.Count > 0) { StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); } StockChart.TechnicalIndicators.Add(indicator); indicator = new BollingerBandIndicator(); NumericalAxis axis = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; UI.Xaml.Charts.SfChart.SetRow(axis, 1); indicator.YAxis = axis; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; StockChart.TechnicalIndicators.Add(indicator); } break; case "Exponential Average": { HiLoOpenCloseSeries series = StockChart.Series[0] as HiLoOpenCloseSeries; ColumnSeries series1 = StockChart.Series[1] as ColumnSeries; ExponentialAverageIndicator indicator = new ExponentialAverageIndicator(); NumericalAxis axis1 = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; indicator.YAxis = axis1; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; if (StockChart.TechnicalIndicators.Count > 0) { StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); } StockChart.TechnicalIndicators.Add(indicator); indicator = new ExponentialAverageIndicator(); NumericalAxis axis = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; UI.Xaml.Charts.SfChart.SetRow(axis, 1); indicator.YAxis = axis; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; StockChart.TechnicalIndicators.Add(indicator); } break; case "MACDTechnical": { HiLoOpenCloseSeries series = StockChart.Series[0] as HiLoOpenCloseSeries; ColumnSeries series1 = StockChart.Series[1] as ColumnSeries; MACDTechnicalIndicator indicator = new MACDTechnicalIndicator(); NumericalAxis axis1 = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; indicator.YAxis = axis1; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; if (StockChart.TechnicalIndicators.Count > 0) { StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); } StockChart.TechnicalIndicators.Add(indicator); indicator = new MACDTechnicalIndicator(); NumericalAxis axis = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; UI.Xaml.Charts.SfChart.SetRow(axis, 1); indicator.YAxis = axis; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; StockChart.TechnicalIndicators.Add(indicator); } break; case "Momentum Technical": { HiLoOpenCloseSeries series = StockChart.Series[0] as HiLoOpenCloseSeries; ColumnSeries series1 = StockChart.Series[1] as ColumnSeries; MomentumTechnicalIndicator indicator = new MomentumTechnicalIndicator(); NumericalAxis axis1 = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; indicator.YAxis = axis1; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; if (StockChart.TechnicalIndicators.Count > 0) { StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); } StockChart.TechnicalIndicators.Add(indicator); indicator = new MomentumTechnicalIndicator(); NumericalAxis axis = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; UI.Xaml.Charts.SfChart.SetRow(axis, 1); indicator.YAxis = axis; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; StockChart.TechnicalIndicators.Add(indicator); } break; case "RSITechnical": { HiLoOpenCloseSeries series = StockChart.Series[0] as HiLoOpenCloseSeries; ColumnSeries series1 = StockChart.Series[1] as ColumnSeries; RSITechnicalIndicator indicator = new RSITechnicalIndicator(); NumericalAxis axis1 = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; indicator.YAxis = axis1; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; if (StockChart.TechnicalIndicators.Count > 0) { StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); } StockChart.TechnicalIndicators.Add(indicator); indicator = new RSITechnicalIndicator(); NumericalAxis axis = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; UI.Xaml.Charts.SfChart.SetRow(axis, 1); indicator.YAxis = axis; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; StockChart.TechnicalIndicators.Add(indicator); } break; case "Simple Average": { HiLoOpenCloseSeries series = StockChart.Series[0] as HiLoOpenCloseSeries; ColumnSeries series1 = StockChart.Series[1] as ColumnSeries; SimpleAverageIndicator indicator = new SimpleAverageIndicator(); NumericalAxis axis1 = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; indicator.YAxis = axis1; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; if (StockChart.TechnicalIndicators.Count > 0) { StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); } StockChart.TechnicalIndicators.Add(indicator); indicator = new SimpleAverageIndicator(); NumericalAxis axis = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; UI.Xaml.Charts.SfChart.SetRow(axis, 1); indicator.YAxis = axis; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; StockChart.TechnicalIndicators.Add(indicator); } break; case "Triangular Average": { HiLoOpenCloseSeries series = StockChart.Series[0] as HiLoOpenCloseSeries; ColumnSeries series1 = StockChart.Series[1] as ColumnSeries; TriangularAverageIndicator indicator = new TriangularAverageIndicator(); NumericalAxis axis1 = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; indicator.YAxis = axis1; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; if (StockChart.TechnicalIndicators.Count > 0) { StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); StockChart.TechnicalIndicators.Remove(StockChart.TechnicalIndicators[0]); } StockChart.TechnicalIndicators.Add(indicator); indicator = new TriangularAverageIndicator(); NumericalAxis axis = new NumericalAxis() { Visibility = Visibility.Collapsed, ShowGridLines = false }; UI.Xaml.Charts.SfChart.SetRow(axis, 1); indicator.YAxis = axis; indicator.ItemsSource = series.ItemsSource; indicator.High = series.High; indicator.Low = series.Low; indicator.Open = series.Open; indicator.Close = series.Close; indicator.XBindingPath = series.XBindingPath; indicator.Volume = series.Open; StockChart.TechnicalIndicators.Add(indicator); } break; } }
private FinancialTechnicalIndicator Addindicator(string value, int rowIndex) { FinancialTechnicalIndicator indicator; switch (value) { case "Accumulation Distribution": indicator = new AccumulationDistributionIndicator(); break; case "Average True Range": indicator = new AverageTrueRangeIndicator() { Period = 1 }; break; case "Bollinger Band": indicator = new BollingerBandIndicator() { UpperLineColor = Brushes.Green, Period = 3 }; break; case "Exponential Average": indicator = new ExponentialAverageIndicator(); break; case "MACD": indicator = new MACDTechnicalIndicator() { Period = 5, LongPeriod = 12, ShortPeriod = 6, ConvergenceLineColor = Brushes.Green }; break; case "Momentum": indicator = new MomentumTechnicalIndicator() { Period = 4 }; break; case "RSI": indicator = new RSITechnicalIndicator() { Period = 4, UpperLineColor = Brushes.Green }; break; case "Simple Average": indicator = new SimpleAverageIndicator(); break; case "Stochastic": indicator = new StochasticTechnicalIndicator() { UpperLineColor = Brushes.Green }; break; case "Triangular Average": indicator = new TriangularAverageIndicator(); break; default: return(null); } var index = rowIndex == 0 ? 1 : 0; ChartSeries Series = this.SfChart.VisibleSeries[index] as ChartSeries; indicator.XBindingPath = "TimeStamp"; indicator.High = "High"; indicator.Low = "Low"; indicator.Open = "Open"; indicator.Close = "Last"; indicator.Volume = "Volume"; Binding binding = new Binding(); binding.Path = new PropertyPath("ItemsSource"); binding.Source = Series; binding.Mode = BindingMode.TwoWay; indicator.SetBinding(FinancialTechnicalIndicator.ItemsSourceProperty, binding); return(indicator); }