Ejemplo n.º 1
0
        protected override void BindCore()
        {
            int currentIndex = 0;

            StochasticFastIndicator owner       = this.Owner as StochasticFastIndicator;
            ChartSeriesModel        model       = this.Owner.Model;
            ChartSeriesModel        signalModel = owner.SignalModel;

            int mainPeriod   = this.MainPeriod;
            int signalPeriod = this.SignalPeriod;

            SizedQueue highValues  = new SizedQueue(mainPeriod);
            SizedQueue lowValues   = new SizedQueue(mainPeriod);
            SizedQueue stochValues = new SizedQueue(signalPeriod);

            foreach (var item in this.itemsSource)
            {
                double high  = (double)this.HighBinding.GetValue(item);
                double low   = (double)this.LowBinding.GetValue(item);
                double close = (double)this.CloseBinding.GetValue(item);

                double mainValue = CalculateMainValue(highValues, lowValues, high, low, close);

                stochValues.EnqueueItem(mainValue);

                double signalValue = MovingAverageIndicatorDataSource.CalculateCurrentValue(stochValues);

                CategoricalDataPoint point, point2;
                if (model.DataPointsInternal.Count > currentIndex)
                {
                    point       = model.DataPointsInternal[currentIndex] as CategoricalDataPoint;
                    point.Value = mainValue;
                }
                else
                {
                    point       = this.GenerateDataPoint(item, -1) as CategoricalDataPoint;
                    point.Value = mainValue;
                    model.DataPointsInternal.Add(point);
                }

                if (signalModel.DataPointsInternal.Count > currentIndex)
                {
                    point2       = signalModel.DataPointsInternal[currentIndex] as CategoricalDataPoint;
                    point2.Value = signalValue;
                }
                else
                {
                    point2       = this.GenerateDataPoint(item, -1) as CategoricalDataPoint;
                    point2.Value = signalValue;
                    signalModel.DataPointsInternal.Add(point2);
                }

                currentIndex++;
            }
        }
Ejemplo n.º 2
0
        private static void OnSignalStrokeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            StochasticFastIndicator indicator = d as StochasticFastIndicator;

            indicator.signalRenderer.strokeShape.Stroke = e.NewValue as Brush;

            if (indicator.isPaletteApplied)
            {
                indicator.UpdatePalette(true);
            }
        }
Ejemplo n.º 3
0
        private static void OnSignalPeriodChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            StochasticFastIndicator presenter = d as StochasticFastIndicator;

            (presenter.dataSource as StochasticIndicatorDataSourceBase).SignalPeriod = (int)e.NewValue;
        }