Exemple #1
0
        private void ToogleZoomingMode(object sender, RoutedEventArgs e)
        {
            switch (ZoomingMode)
            {
            case ZoomingOptions.None:
                ZoomingMode = ZoomingOptions.X;
                break;

            case ZoomingOptions.X:
                ZoomingMode = ZoomingOptions.Y;
                break;

            case ZoomingOptions.Y:
                ZoomingMode = ZoomingOptions.Xy;
                break;

            case ZoomingOptions.Xy:
                ZoomingMode = ZoomingOptions.None;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
 private void XyOnClick(object sender, RoutedEventArgs e)
 {
     ZoomingMode = ZoomingOptions.XY;
 }
Exemple #3
0
 private void YOnClick(object sender, RoutedEventArgs e)
 {
     ZoomingMode = ZoomingOptions.Y;
 }
 private void ToogleZoomingMode(object sender, RoutedEventArgs e)
 {
     switch (ZoomingMode)
     {
         case ZoomingOptions.None:
             ZoomingMode = ZoomingOptions.X;
             break;
         case ZoomingOptions.X:
             ZoomingMode = ZoomingOptions.Y;
             break;
         case ZoomingOptions.Y:
             ZoomingMode = ZoomingOptions.Xy;
             break;
         case ZoomingOptions.Xy:
             ZoomingMode = ZoomingOptions.None;
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
 public SeriesViewModel()
 {
     this.SeriesCollection = new SeriesCollection();
     this.YFormatter       = value => value.ToString("f");
     this.ZoomingMode      = ZoomingOptions.X;
 }
Exemple #6
0
        private async void UpdateData_Click(object sender, RoutedEventArgs e)
        {
            ChartValues <DateTimePoint> _values = await GetData();

            // calc high point

            double VQ                = 9.10; // VTI volatility, %
            int    count             = _values.Count;
            var    array_high        = new DateTimePoint[count];
            var    array_mid_warning = new DateTimePoint[count];
            var    array_low         = new DateTimePoint[count];
            var    high_point        = _values[0].Value;

            array_high[0]        = new DateTimePoint(_values[0].DateTime, high_point);
            array_mid_warning[0] = new DateTimePoint(_values[0].DateTime, high_point * (1 - VQ / 100 / 2));
            array_low[0]         = new DateTimePoint(_values[0].DateTime, high_point * (1 - VQ / 100));
            for (var i = 1; i <= count - 1; i++)
            {
                if (_values[i].Value >= high_point)
                {
                    high_point = _values[i].Value;
                }
                else if (high_point * (1 - VQ / 100) >= _values[i].Value)  //   later time price is lower than the previous price ...  _values[i + 1].Value < _values[i].Value
                {
                    high_point = _values[i].Value;
                }
                array_high[i]        = new DateTimePoint(_values[i].DateTime, high_point);
                array_mid_warning[i] = new DateTimePoint(_values[i].DateTime, high_point * (1 - VQ / 100 / 2));
                array_low[i]         = new DateTimePoint(_values[i].DateTime, high_point * (1 - VQ / 100));
            }

            var values_high = new ChartValues <DateTimePoint>();
            var values_mid  = new ChartValues <DateTimePoint>();
            var values_low  = new ChartValues <DateTimePoint>();

            values_high.AddRange(array_high);
            values_mid.AddRange(array_mid_warning);
            values_low.AddRange(array_low);

            SeriesCollection = new SeriesCollection
            {
                new LineSeries
                {
                    Title             = "Highest Price",
                    Values            = values_high,
                    Fill              = Brushes.Green,
                    Stroke            = Brushes.Green,
                    LineSmoothness    = 0,
                    StrokeThickness   = 1,
                    PointGeometrySize = 0
                },
                new LineSeries
                {
                    Title             = "Mid Price (Warning)",
                    Values            = values_mid,
                    Fill              = Brushes.Yellow,
                    Stroke            = Brushes.Yellow,
                    LineSmoothness    = 0,
                    StrokeThickness   = 1,
                    PointGeometrySize = 0
                },

                new LineSeries
                {
                    Title  = "Trailing Stop",
                    Values = values_low,
                    //Fill = Brushes.Red,
                    Stroke            = Brushes.Red,
                    LineSmoothness    = 0,
                    StrokeThickness   = 1,
                    PointGeometrySize = 0
                },
                new LineSeries
                {
                    Title  = "close price",
                    Values = _values,
                    //Fill = Brushes.Yellow,
                    Stroke            = Brushes.White,
                    LineSmoothness    = 0,
                    StrokeThickness   = 3,
                    PointGeometrySize = 0,
                },
            };

            ZoomingMode = ZoomingOptions.X;

            XFormatter = val => new DateTime((long)val).ToString("yy-MM-dd");
            YFormatter = val => val.ToString("C");

            DataContext = this;
        }