void Indicator_Checked(object sender, RoutedEventArgs e) { ChartTechnicalIndicator indicator = new ChartTechnicalIndicator(); indicator.IndicatorType = IndicatorTypes.Stochastics; ser1.Indicators.Items.Add(indicator); syncChart1.Areas[0].SplitterPosition = .6; if (syncChart1.Areas.Count > 1) { ChartStochastics.SetLowerLineColor(ser1.Indicators.Items[ser1.Indicators.Items.Count - 1], Brushes.DarkOrchid); ChartStochastics.SetUpperLineColor(ser1.Indicators.Items[ser1.Indicators.Items.Count - 1], Brushes.DarkOrchid); ChartStochastics.SetSignalLineColor(ser1.Indicators.Items[ser1.Indicators.Items.Count - 1], Brushes.DarkOrchid); ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].stocasticsArea.Background = this.Resources["transparentBackground"] as SolidColorBrush; ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].stocasticsArea.SecondaryAxis.LineStroke = this.Resources["linestroke"] as Pen; ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].stocasticsArea.SecondaryAxis.IntersectAction = ChartLabelIntersectAction.Hide; ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].stocasticsArea.SecondaryAxis.EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift; ChartArea.SetGridLineStroke(ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].stocasticsArea.SecondaryAxis, this.Resources["gridstroke"] as Pen); ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].stocasticsArea.SecondaryAxis.OpposedPosition = true; ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].stocasticsArea.SecondaryAxis.LabelTemplate = this.Resources["YAxistemplate"] as DataTemplate; for (int i = 0; i < syncChart1.Areas.Count; i++) { SetHorizontalScale(syncChart1.Areas[i]); } } ChartLayer layer = new ChartLayer(); layer.LayerIndicatorName = "Stochastics"; layer.ParmsToParmString(defaultParams); ChartFastSeriesPresenter.SetPen(ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].stocasticsArea.Series[0], new Pen() { Brush = Brushes.DarkOrchid, Thickness = 2d, DashStyle = DashStyles.Dash }); ChartFastSeriesPresenter.SetPen(ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].stocasticsArea.Series[1], new Pen() { Brush = Brushes.DarkOrchid, Thickness = 2d, DashStyle = DashStyles.Dash }); ChartFastSeriesPresenter.SetPen(ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].stocasticsArea.Series[2], new Pen() { Brush = Brushes.DarkOrchid, Thickness = 2d, DashStyle = DashStyles.Solid }); foreach (ChartSeries series in ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].stocasticsArea.Series) { AddNotes(series, layer, 5); } for (int i = 0; i < syncChart1.Areas.Count; i++) { SetHorizontalScale(syncChart1.Areas[i]); } }
public void AddNotes(ChartSeries series, ChartLayer layer, int position) { AnnotationsCollection annotations = new AnnotationsCollection(); ChartSeriesAnnotation annotation = new ChartSeriesAnnotation(); //annotation.Header = layer.Note; if (layer.NoteVisibility == NoteVisibilityState.Opened) { annotation.Stroke = new SolidColorBrush(layer.StrokeColor); annotation.Template = this.Resources["AnnotationTemplateText"] as DataTemplate; } else { annotation.Template = this.Resources["AnnotationTemplate"] as DataTemplate; } annotation.X = series.Data[position].X; annotation.Y = series.Data[position].Y; annotations.Items.Add(annotation); series.Annotations = annotations; }