Example #1
0
        void Indicator_Checked(object sender, RoutedEventArgs e)
        {
            ChartTechnicalIndicator indicator = new ChartTechnicalIndicator();

            indicator.IndicatorType = IndicatorTypes.RelativeStrengthIndex;
            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.IndianRed);
                //ChartStochastics.SetUpperLineColor(ser1.Indicators.Items[ser1.Indicators.Items.Count - 1], Brushes.IndianRed);
                //ChartStochastics.SetSignalLineColor(ser1.Indicators.Items[ser1.Indicators.Items.Count - 1], Brushes.IndianRed);
                ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].rsiArea.Background = this.Resources["transparentBackground"] as SolidColorBrush;
                ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].rsiArea.SecondaryAxis.LineStroke            = this.Resources["linestroke"] as Pen;
                ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].rsiArea.SecondaryAxis.IntersectAction       = ChartLabelIntersectAction.Hide;
                ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].rsiArea.SecondaryAxis.EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift;
                ChartArea.SetGridLineStroke(ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].rsiArea.SecondaryAxis, this.Resources["gridstroke"] as Pen);
                ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].rsiArea.SecondaryAxis.OpposedPosition = true;
                ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].rsiArea.SecondaryAxis.LabelTemplate   = this.Resources["YAxistemplate"] as DataTemplate;
                ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].rsiArea.SecondaryAxis.IsAutoSetRange  = false;
                ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].rsiArea.SecondaryAxis.Range           = new DoubleRange(0, 100);

                for (int i = 0; i < syncChart1.Areas.Count; i++)
                {
                    SetHorizontalScale(syncChart1.Areas[i]);
                }
            }
            ChartLayer layer = new ChartLayer();

            layer.LayerIndicatorName = "Relative Strength Index";
            layer.ParmsToParmString(defaultParams);

            foreach (ChartSeries series in ser1.Indicators.Items[ser1.Indicators.Items.Count - 1].rsiArea.Series)
            {
                AddNotes(series, layer, 5);
            }
            for (int i = 0; i < syncChart1.Areas.Count; i++)
            {
                SetHorizontalScale(syncChart1.Areas[i]);
            }
        }
Example #2
0
        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;
        }