protected virtual void SetSeriesOvers(FinancialChart chart, FinancialSeries primary, double overBoughtValue, Color overBoughtColor, double overSoldValue, Color overSoldColor, bool showZones) { FinancialSeries serOverBought = chart.Series.FirstOrDefault(p => p.Name == primary.Name + "OverBought") as FinancialSeries; FinancialSeries serOverSold = chart.Series.FirstOrDefault(p => p.Name == primary.Name + "OverSold") as FinancialSeries; if (serOverBought == null || serOverSold == null) { serOverBought = new FinancialSeries() { ChartType = FinancialChartType.Line, Name = primary.Name + "OverBought", Binding = "Y" }; serOverSold = new FinancialSeries() { ChartType = FinancialChartType.Line, Name = primary.Name + "OverSold", Binding = "X" }; serOverSold.AxisY = serOverBought.AxisY = primary.AxisY; serOverSold.Style.StrokeWidth = serOverBought.Style.StrokeWidth = 1; chart.Series.Add(serOverBought); chart.Series.Add(serOverSold); } serOverBought.Style.StrokeColor = overBoughtColor; serOverSold.Style.StrokeColor = overSoldColor; serOverBought.Visibility = serOverSold.Visibility = showZones ? C1.Chart.SeriesVisibility.Plot : C1.Chart.SeriesVisibility.Hidden; if (showZones) { PointF[] pts = new PointF[primary.GetCount()]; pts = pts.Select((p) => p = new PointF((float)overSoldValue, (float)overBoughtValue)).ToArray(); serOverSold.DataSource = serOverBought.DataSource = pts; } }
private void overlayType_SelectedIndexChanged(object sender, EventArgs e) { FinancialSeries ser = null; if (overlayType.SelectedIndex == 0) { ser = bollingerBands; } else if (overlayType.SelectedIndex == 1) { ser = envelopes; } else if (overlayType.SelectedIndex == 2) { ser = ichimokuCloud; } else if (overlayType.SelectedIndex == 3) { ser = alligator; } else if (overlayType.SelectedIndex == 4) { ser = zigZag; } UpdateControls(ser); if (ser != null && !financialChart1.Series.Contains(ser)) { financialChart1.Series.Clear(); financialChart1.Series.Add(defaultSeries); financialChart1.Series.Add(ser); } }
void InitializeBottomChart(SymbolData data) { financialChart2.BeginUpdate(); financialChart2.BindingX = "Date"; financialChart2.Binding = "Close"; financialChart2.AxisY.Position = Position.None; var cs = new FinancialSeries(); cs.Style.StrokeWidth = 2; cs.Style.FillColor = Color.FromArgb(255, 165, 0); cs.Style.StrokeColor = Color.FromArgb(255, 165, 0); financialChart2.Series.Add(cs); financialChart2.ChartType = FinancialChartType.Line; financialChart2.DataSource = data; financialChart2.ToolTip.Content = null; financialChart2.AxisX.Min = new DateTime(2007, 12, 31, 0, 0, 0).ToOADate(); financialChart2.EndUpdate(); financialChart2.Rendered += (s1, e1) => RefreshRangeSelector(); }
private void indicatorType_SelectedIndexChanged(object sender, EventArgs e) { FinancialSeries ser = null; if (indicatorType.SelectedIndex == 0) { ser = atr; } else if (indicatorType.SelectedIndex == 1) { ser = rsi; } else if (indicatorType.SelectedIndex == 2) { ser = cci; } else if (indicatorType.SelectedIndex == 3) { ser = wi; } else if (indicatorType.SelectedIndex == 4) { ser = macd; } else if (indicatorType.SelectedIndex == 5) { ser = stochastic; } UpdateControls(ser); if (ser != null && !financialChart2.Series.Contains(ser)) { financialChart2.Series.Clear(); financialChart2.Series.Add(ser); if (ser is Macd) { financialChart2.Series.Add(macdHistogram); } } }
private void UpdateControls(FinancialSeries series) { string name = series.Name; for (int i = 2; i < flowLayoutPanel1.Controls.Count; i++) { var ctrl = flowLayoutPanel1.Controls[i]; ctrl.Visible = false; } if (series is ATR || series is RSI || series is CCI || series is WilliamsR) { label2.Visible = true; period.Visible = true; } else if (series is Macd) { label3.Visible = true; label4.Visible = true; label5.Visible = true; nudFastPeriod.Visible = true; nudFastPeriod.Value = macd.FastPeriod; nudSlowPeriod.Visible = true; nudSlowPeriod.Value = macd.SlowPeriod; nudMacdSignalSmoothingPeriod.Visible = true; nudMacdSignalSmoothingPeriod.Value = macd.SmoothingPeriod; } else if (series is Stochastic) { label6.Visible = true; label7.Visible = true; label8.Visible = true; nudKPeriod.Visible = true; nudKPeriod.Value = stochastic.KPeriod; nudDPeriod.Visible = true; nudDPeriod.Value = stochastic.DPeriod; nudStochasticSmoothingPeriod.Visible = true; nudStochasticSmoothingPeriod.Value = stochastic.SmoothingPeriod; } }
private void InitOverlays() { defaultSeries = new FinancialSeries() { Name = "Box" }; bollingerBands = new BollingerBands() { Name = "Bollinger Bands" }; envelopes = new Envelopes() { Name = "Envoloper" }; ichimokuCloud = new IchimokuCloud() { Name = "Ichimoku Cloud", ConversionLineStyle = new C1.Win.Chart.ChartStyle() { StrokeColor = Color.Orange }, BaseLineStyle = new C1.Win.Chart.ChartStyle() { StrokeColor = Color.Blue }, LaggingLineStyle = new C1.Win.Chart.ChartStyle() { StrokeColor = Color.Black }, LeadingSpanALineStyle = new C1.Win.Chart.ChartStyle() { StrokeColor = Color.LightGreen }, LeadingSpanBLineStyle = new C1.Win.Chart.ChartStyle() { StrokeColor = Color.IndianRed }, BullishCloudColor = new SolidBrush(Color.LightGreen), BearishCloudColor = new SolidBrush(Color.IndianRed) }; zigZag = new ZigZag() { Name = "ZigZag" }; zigZag.Style.StrokeColor = Color.Green; zigZag.Style.StrokeWidth = 0.8f; alligator = new Alligator() { Name = "Alligator", JawLineStyle = new C1.Win.Chart.ChartStyle() { StrokeColor = Color.LightGreen }, TeethLineStyle = new C1.Win.Chart.ChartStyle() { StrokeColor = Color.IndianRed }, LipsLineStyle = new C1.Win.Chart.ChartStyle() { StrokeColor = Color.Black }, }; }
private void UpdateControls(FinancialSeries series) { string name = series.Name; for (int i = 4; i < flowLayoutPanel1.Controls.Count; i++) { var ctrl = flowLayoutPanel1.Controls[i]; ctrl.Visible = false; } if (series is BollingerBands) { label3.Visible = true; nudMultiplier.Visible = true; nudMultiplier.Value = bollingerBands.Multiplier; } else if (series is Envelopes) { label4.Visible = true; label5.Visible = true; nudSize.Visible = true; mvaType.Visible = true; } else if (series is IchimokuCloud) { label2.Visible = false; period.Visible = false; conversionLabel.Visible = true; conversionPeriod.Visible = true; baseLabel.Visible = true; basePeriod.Visible = true; leadingLabel.Visible = true; leadingPeriod.Visible = true; laggingLabel.Visible = true; laggingPeriod.Visible = true; } else if (series is Alligator) { label2.Visible = false; period.Visible = false; jawPeriodLabel.Visible = true; jawPeriodNumberic.Visible = true; teethPeriodLabel.Visible = true; teethPeriodNumberic.Visible = true; lipsPeriodLabel.Visible = true; lipsPeriodNumberic.Visible = true; } else if (series is ZigZag) { label2.Visible = false; period.Visible = false; zigZagDistanceLabel.Visible = true; zigZagDistanceNumberic.Visible = true; } }
public VolumeSeries(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 = "Vol"; AxisY.Labels = false; AxisY.MajorTickMarks = AxisY.MinorTickMarks = C1.Chart.TickMark.None; FinancialSeries series = new FinancialSeries(); series.ChartType = C1.Chart.Finance.FinancialChartType.ColumnVolume; 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 = "Volume,Close"; double[] values = null; ViewModel.ViewModel.Instance.PropertyChanged += (o, e) => { if (e.PropertyName == "CurrectQuote") { values = series.GetValues(2); // this is the closing value; } }; series.SymbolRendering += (sender, ev) => { if (ev.Index == 0) { return; } if (values == null) { values = series.GetValues(2); // this is the closing value; } if (values != null) { if (values[ev.Index - 1] > values[ev.Index]) { if (DownVolume is SolidColorBrush) { Color c = (DownVolume as SolidColorBrush).Color; Color cf = Color.FromArgb(128, c.R, c.G, c.B); ev.Engine.SetStroke(c.ToArgb()); ev.Engine.SetFill(cf.ToArgb()); } } else { if (UpVolume is SolidColorBrush) { Color c = (UpVolume as SolidColorBrush).Color; Color cf = Color.FromArgb(128, c.R, c.G, c.B); ev.Engine.SetStroke(c.ToArgb()); ev.Engine.SetFill(cf.ToArgb()); } } } }; series.AxisY = AxisY; Chart.Series.Add(series); //Utilities.Helper.BindingSettingsParams(chart, series, typeof(FinancialSeries), "Volume", // new Data.PropertyParam[] // { // new Data.PropertyParam("Style.Fill", typeof(Brush)), // new Data.PropertyParam("Style.Stroke", typeof(Brush)), // }, // () => // { // this.OnSettingParamsChanged(); // } //); Utilities.Helper.BindingSettingsParams(chart, this, typeof(VolumeSeries), "Volume", new Data.PropertyParam[] { new Data.PropertyParam("UpVolume", typeof(Brush)), new Data.PropertyParam("DownVolume", typeof(Brush)), }, () => { this.OnSettingParamsChanged(); } ); //binding series color to axis title. Binding binding = new Binding("UpVolume"); binding.Source = this; BindingOperations.SetBinding(AxisY.TitleStyle, ChartStyle.StrokeProperty, binding); Chart.EndUpdate(); this.Series = new FinancialSeries[] { series }; }