void Indicator_Checked(object sender, RoutedEventArgs e) { ChartTechnicalIndicator indicator = new ChartTechnicalIndicator(); indicator.IndicatorType = IndicatorTypes.Momentum; ChartMomentum.SetMomentumTimeSpan(indicator, 10); ser1.Indicators.Items.Add(indicator); syncChart1.Areas[0].SplitterPosition = .6; if (syncChart1.Areas.Count > 1) { ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].momentumArea.Background = this.Resources["transparentBackground"] as SolidColorBrush; ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].momentumArea.SecondaryAxis.LineStroke = this.Resources["linestroke"] as Pen; ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].momentumArea.SecondaryAxis.IntersectAction = ChartLabelIntersectAction.Hide; ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].momentumArea.SecondaryAxis.EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift; ChartArea.SetGridLineStroke(ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].momentumArea.SecondaryAxis, this.Resources["gridstroke"] as Pen); ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].momentumArea.SecondaryAxis.OpposedPosition = true; ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].momentumArea.SecondaryAxis.LabelTemplate = this.Resources["YAxistemplate"] as DataTemplate; for (int i = 0; i < syncChart1.Areas.Count; i++) { SetHorizontalScale(syncChart1.Areas[i]); } } ChartLayer layer = new ChartLayer(); if (layer != null && layer.NoteVisibility != NoteVisibilityState.Hidden) { foreach (ChartSeries series in ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].momentumArea.Series) { AnnotationsCollection annotations = new AnnotationsCollection(); ChartSeriesAnnotation annotation = new ChartSeriesAnnotation(); //annotation.Header = layer.Note + ChartMomentum.GetMomentumTimeSpan(indicator).ToString(); 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[leftVisibleIndex + 5].X; annotation.Y = series.Data[leftVisibleIndex + 5].Y; annotations.Items.Add(annotation); series.Annotations = annotations; } } }
public void AddNotes(ChartSeries series, ChartLayer layer, int avgValue, int position) { AnnotationsCollection annotations = new AnnotationsCollection(); ChartSeriesAnnotation annotation = new ChartSeriesAnnotation(); //annotation.Header = layer.Note + avgValue.ToString(); 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; }