This is a migrated thread and some comments may be shown as answers.

Financial Indicator doesn't update when data source changed

1 Answer 89 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Sergey
Top achievements
Rank 1
Sergey asked on 27 Jan 2014, 02:36 PM
Hi, I have problem with binding ObservableCollection on ItemsSource of FinancialIndicator. When I bound CandleChart series, I haven't problem.


<StackPanel Grid.Row="2" Orientation="Vertical">
            <StackPanel Orientation="Horizontal">
                <ComboBox x:Name="IndicatorComboBox" MinWidth="150" Width="Auto" ItemsSource="{Binding IndicatorCollection}" SelectedItem="{Binding SelectedIndicator}" >
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <i:InvokeCommandAction Command="{Binding ElementName=IndicatorComboBox,Path=SelectedItem.ApplyPararmetersComand}" CommandParameter="{Binding ElementName=IndicatorChart}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Path=DisplayName}"/>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
                <!--<ContentPresenter Content="{Binding ElementName=IndicatorComboBox,Path=SelectedItem }"  />-->
                <Button  Content="Apply" Command="{Binding ElementName=IndicatorComboBox,Path=SelectedItem.ApplyPararmetersComand}" CommandParameter="{Binding ElementName=IndicatorChart}" />
            </StackPanel>
            <ContentPresenter Content="{Binding Path=SelectedIndicator}" />

            
        </StackPanel>

-------
 <ControlTemplate x:Key="StohasticIndicator" >
        <StackPanel Orientation="Vertical" >
        <WrapPanel Orientation="Horizontal">
            <TextBlock Text="SignalPeriod:" />
            <TextBox Text="{Binding Path=SignalPeriod,Mode=TwoWay}"/>
            <TextBlock Text="MainPeriod:" />
            <TextBox Text="{Binding Path=MainPeriod,Mode=TwoWay}"/>
            <TextBlock Text="Slowing:" />
            <TextBox Text="{Binding Path=SlowingPeriod,Mode=TwoWay}"/>
        </WrapPanel>
            <telerik:RadCartesianChart x:Name="IndicatorChart" DataContext="{Binding}"  Visibility="{Binding IndicatorVisibility}" Zoom="{Binding Path=DataContext.IndicatorChartZoom, RelativeSource={RelativeSource AncestorType=vw:CandleChartView, Mode=FindAncestor}}" Width="Auto" >
                <telerik:RadCartesianChart.HorizontalAxis>
                    <telerik:DateTimeContinuousAxis ShowLabels="True"
                                                MajorStep="{Binding Path=DataContext.MajorStep, RelativeSource={RelativeSource AncestorType=vw:CandleChartView, Mode=FindAncestor}}"
                                                MajorStepUnit="Minute"
                                                LabelInterval="6"
                                                LabelTemplate="{StaticResource axisLabelTemplate}"
                                                PlotMode="OnTicksPadded"
                                                Minimum="{Binding Path=DataContext.MinTime, RelativeSource={RelativeSource AncestorType=vw:CandleChartView,Mode=FindAncestor}}"  
                                                Maximum="{Binding Path=DataContext.MaxTime, RelativeSource={RelativeSource AncestorType=vw:CandleChartView,Mode=FindAncestor}}"
                                                >
                    </telerik:DateTimeContinuousAxis>
                </telerik:RadCartesianChart.HorizontalAxis>
                <telerik:RadCartesianChart.VerticalAxis>
                    <telerik:LinearAxis Minimum="0" Maximum="100" LabelInterval="2"  />
                </telerik:RadCartesianChart.VerticalAxis>
                <telerik:RadCartesianChart.Behaviors>
                    <telerik:ChartPanAndZoomBehavior ZoomMode="None" PanMode="Horizontal"   />
                </telerik:RadCartesianChart.Behaviors>
                <telerik:RadCartesianChart.Series>
                    <telerik:CandlestickSeries x:Name="s1" ItemsSource="{Binding Path=Source}"                                           
                                               OpenBinding="OpenPrice"
                                               HighBinding="HightPrice"
                                               LowBinding="LowPrice"
                                               CloseBinding="ClosePrice"
                                               CategoryBinding="StartTime" >

                    </telerik:CandlestickSeries>
                    
                </telerik:RadCartesianChart.Series>
                <telerik:RadCartesianChart.Indicators >

                    <!--<telerik:StochasticFastIndicator ItemsSource="{Binding Path=DataContext.Candles, RelativeSource={RelativeSource AncestorType=vw:CandleChartView, Mode=FindAncestor}}" CategoryBinding="StartTime" CloseBinding="ClosePrice" HighBinding="HightPrice" LowBinding="LowPrice" Stroke="Blue" StrokeThickness="1" MainPeriod="{Binding MainPeriod}" SignalPeriod="{Binding SignalPeriod}" />-->
                    <telerik:StochasticFastIndicator  ItemsSource="{Binding Path=Source}" CategoryBinding="StartTime" CloseBinding="ClosePrice" HighBinding="HightPrice" LowBinding="LowPrice" Stroke="Blue" StrokeThickness="1" MainPeriod="{Binding MainPeriod}" SignalPeriod="{Binding SignalPeriod}" />
                    <telerik:StochasticSlowIndicator ItemsSource="{Binding Path=Source}" CategoryBinding="StartTime" CloseBinding="ClosePrice" HighBinding="HightPrice" LowBinding="LowPrice" Stroke="Red" StrokeThickness="1" MainPeriod="{Binding MainPeriod}" SignalPeriod="{Binding SignalPeriod}" SlowingPeriod="{Binding SlowingPeriod}" />

                </telerik:RadCartesianChart.Indicators>
                <telerik:RadCartesianChart.Annotations>
                    <telerik:CartesianGridLineAnnotation Value="80" Axis="{Binding ElementName=IndicatorChart, Path=VerticalAxis}" StrokeThickness="1" Stroke="Black"  Label="80" />
                    <telerik:CartesianGridLineAnnotation Value="20" Axis="{Binding ElementName=IndicatorChart, Path=VerticalAxis}" StrokeThickness="1" Stroke="Black" Label="20" />
                </telerik:RadCartesianChart.Annotations>

            </telerik:RadCartesianChart>
        </StackPanel>
    </ControlTemplate>
    <DataTemplate DataType="{x:Type models:StohasticIndicator}">
        <Control Template="{StaticResource ResourceKey=StohasticIndicator}" DataContext="{Binding}" />
    </DataTemplate>
---------------------
Source is ObservableCollection of Candle , and some times updates from external service.

public class Candle : INotifyPropertyChanged
    {
        private Dispatcher dispatcher = Dispatcher.CurrentDispatcher;

        private double _openPrice;

        private double _closePrice;

        private double _hightPrice;

        private double _lowPrice;

        private double _volume;

        private DateTimeOffset _startTime;

        private DateTimeOffset _endTime;

        public double OpenPrice
        {
            get { return _openPrice; }
            set
            {
                if (value != _openPrice)
                {
                    _openPrice = value;
                    OnPropertyChanged("OpenPrice");
                }
            }
        }

        public double ClosePrice
        {
            get { return _closePrice; }
            set
            {
                if(value != _closePrice)
                {
                    _closePrice = value;
                    OnPropertyChanged("ClosePrice");
                }
            }
        }

        public double HightPrice
        {
            get { return _hightPrice; }
            set
            {
                if (value != _hightPrice)
                {
                    _hightPrice = value;
                    OnPropertyChanged("HightPrice");
                }
            }
        }

        public double LowPrice
        {
            get { return _lowPrice; }
            set
            {
                if (value != _lowPrice)
                {
                    _lowPrice = value;
                    OnPropertyChanged("LowPrice");
                }
            }
        }

        public double Volume
        {
            get { return _volume; }
            set
            {
                if (_volume != value)
                {
                    _volume = value;
                    OnPropertyChanged("Volume");
                }
            }
        }

        public DateTimeOffset StartTime
        {
            get { return _startTime; }
            set
            {
                if (_startTime != value)
                {
                    _startTime = value;
                    OnPropertyChanged("StartTime");
                }
            }
        }

        public DateTimeOffset EndTime
        {
            get { return _endTime; }
            set
            {
                if (_endTime != value)
                {
                    _endTime = value;
                    OnPropertyChanged("EndTime");
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string name)
        {
          

            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
               
                    dispatcher.BeginInvoke(DispatcherPriority.Normal,
                               (ThreadStart)delegate()
                               {
                                   PropertyChanged(this, new PropertyChangedEventArgs(name));
                               });
               
            }          
        }
    }

CandleSeries  updates normal, but Financial indicator doesn't work. Help, please :)

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 30 Jan 2014, 02:36 PM
Hello Sergey,

We couldn't reproduce the issue on our side with our latest official release. This is why we kindly ask you to provide us with your data and tell us how you change the data and what is expected to be changed in the financial indicator that you are currently using? Please note that it might be expected that the financial indicator is not changing. Basically, this depends on the data used by the indicator and the change that is made to the data.

Please contact your license holder and log in your Telerik account. This will allow you to use our ticketing system and attach a ZIP file with running project in a new thread. This project will help us further investigate your custom scenario.

Thank you for your cooperation.

Regards,
Martin Ivanov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ChartView
Asked by
Sergey
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or