public RSISeries(C1FlexChart chart, string plotAreaName) : base() { Chart = chart; Chart.BeginUpdate(); AxisY.TitleStyle = new ChartStyle(); AxisY.TitleStyle.FontWeight = Windows.UI.Text.FontWeights.Bold; AxisY.Position = C1.Chart.Position.Right; AxisY.PlotAreaName = plotAreaName; AxisY.Title = "RSI"; AxisY.Labels = false; AxisY.MajorTickMarks = AxisY.MinorTickMarks = C1.Chart.TickMark.None; RSI series = new RSI(); series.ChartType = C1.Chart.Finance.FinancialChartType.Line; series.Style = new ChartStyle(); series.Style.StrokeThickness = 1; series.BindingX = "Date"; series.Binding = "High,Low,Close"; series.AxisY = AxisY; Chart.Series.Add(series); ThresholdSeries overBought = new ThresholdSeries(); overBought.ChartType = C1.Chart.Finance.FinancialChartType.Line; overBought.Style = new ChartStyle(); overBought.Style.Stroke = new SolidColorBrush(ViewModel.IndicatorPalettes.StockGreen); overBought.Style.StrokeThickness = 1; overBought.AxisY = AxisY; Chart.Series.Add(overBought); ThresholdSeries overSold = new ThresholdSeries(); overSold.ChartType = C1.Chart.Finance.FinancialChartType.Line; overSold.Style = new ChartStyle(); overSold.Style.Stroke = new SolidColorBrush(ViewModel.IndicatorPalettes.StockRed); overSold.Style.StrokeThickness = 1; overSold.AxisY = AxisY; Chart.Series.Add(overSold); Utilities.Helper.BindingSettingsParams(chart, series, typeof(RSI), "Relative Strength Index (RSI)", new Data.PropertyParam[] { new Data.PropertyParam("Period", typeof(int)), new Data.PropertyParam("Style.Stroke", typeof(Brush)), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, overBought, typeof(ThresholdSeries), "Relative Strength Index (RSI)", new Data.PropertyParam[] { new Data.PropertyParam("ZonesVisibility", typeof(bool)), new Data.PropertyParam("Threshold", typeof(int), "OverBought"), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, overSold, typeof(ThresholdSeries), "Relative Strength Index (RSI)", new Data.PropertyParam[] { new Data.PropertyParam("ZonesVisibility", typeof(bool)), new Data.PropertyParam("Threshold", typeof(int), "OverSold"), }, () => { this.OnSettingParamsChanged(); } ); overBought.OnThesholdChanged += (o, e) => { this.OnSettingParamsChanged(); }; overSold.OnThesholdChanged += (o, e) => { this.OnSettingParamsChanged(); }; //binding series color to axis title. Binding binding = new Binding(); binding.Path = new Windows.UI.Xaml.PropertyPath("Stroke"); binding.Source = series.Style; BindingOperations.SetBinding(AxisY.TitleStyle, ChartStyle.StrokeProperty, binding); Chart.EndUpdate(); this.Series = new FinancialSeries[] { series, overBought, overSold }; }
public StochasticSeries(C1FlexChart chart, string plotAreaName) : base() { Chart = chart; Chart.BeginUpdate(); AxisY.TitleStyle = new ChartStyle(); AxisY.TitleStyle.FontWeight = FontWeights.Bold; AxisY.Position = C1.Chart.Position.Right; AxisY.PlotAreaName = plotAreaName; AxisY.Title = "Stoc"; AxisY.Labels = false; AxisY.MajorTickMarks = AxisY.MinorTickMarks = C1.Chart.TickMark.None; series = new Stochastic(); series.DLineStyle = new ChartStyle(); series.DLineStyle.StrokeThickness = 1; series.KLineStyle = new ChartStyle(); series.KLineStyle.StrokeThickness = 1; series.ChartType = C1.Chart.Finance.FinancialChartType.Line; series.Style = new C1.WPF.Chart.ChartStyle(); series.Style.Stroke = new SolidColorBrush(Color.FromArgb(255, 51, 103, 214)); series.Style.Fill = new SolidColorBrush(Color.FromArgb(128, 66, 133, 244)); series.Style.StrokeThickness = 1; series.BindingX = "Date"; series.Binding = "High,Low,Close"; series.AxisY = AxisY; Chart.Series.Add(series); ThresholdSeries overBought = new ThresholdSeries(); overBought.ChartType = C1.Chart.Finance.FinancialChartType.Line; overBought.Style = new C1.WPF.Chart.ChartStyle(); overBought.Style.Stroke = new SolidColorBrush(ViewModel.IndicatorPalettes.StockGreen); overBought.Style.StrokeThickness = 1; overBought.AxisY = AxisY; Chart.Series.Add(overBought); ThresholdSeries overSold = new ThresholdSeries(); overSold.ChartType = C1.Chart.Finance.FinancialChartType.Line; overSold.Style = new C1.WPF.Chart.ChartStyle(); overSold.Style.Stroke = new SolidColorBrush(ViewModel.IndicatorPalettes.StockRed); overSold.Style.StrokeThickness = 1; overSold.AxisY = AxisY; Chart.Series.Add(overSold); Utilities.Helper.BindingSettingsParams(chart, this, typeof(StochasticSeries), "Stochastic", new Data.PropertyParam[] { new Data.PropertyParam("StochasticType", typeof(StochasticPresetType)), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, series, typeof(Stochastic), "Stochastic", new Data.PropertyParam[] { new Data.PropertyParam("KPeriod", typeof(int)), new Data.PropertyParam("DPeriod", typeof(int)), new Data.PropertyParam("SmoothingPeriod", typeof(int)), new Data.PropertyParam("DLineStyle.Stroke", typeof(Brush)), new Data.PropertyParam("KLineStyle.Stroke", typeof(Brush)), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, overBought, typeof(ThresholdSeries), "Stochastic", new Data.PropertyParam[] { new Data.PropertyParam("ZonesVisibility", typeof(bool)), new Data.PropertyParam("Threshold", typeof(int), "OverBought"), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, overSold, typeof(ThresholdSeries), "Stochastic", new Data.PropertyParam[] { new Data.PropertyParam("ZonesVisibility", typeof(bool)), new Data.PropertyParam("Threshold", typeof(int), "OverSold"), }, () => { this.OnSettingParamsChanged(); } ); overBought.OnThesholdChanged += (o, e) => { this.OnSettingParamsChanged(); }; overSold.OnThesholdChanged += (o, e) => { this.OnSettingParamsChanged(); }; //binding series color to axis title. Binding binding = new Binding("Stroke"); binding.Source = series.Style; BindingOperations.SetBinding(AxisY.TitleStyle, ChartStyle.StrokeProperty, binding); Chart.EndUpdate(); this.Series = new FinancialSeries[] { series, overBought, overSold }; }