Add Outlook Inspired and Stock Market demos

This commit is contained in:
maxerokh
2018-12-13 18:49:44 +03:00
parent b5cab35919
commit 2e45b5d38f
833 changed files with 124450 additions and 47 deletions

View File

@@ -0,0 +1,107 @@
using DevExpress.XtraCharts;
namespace DevExpress.StockMarketTrader {
public class MedianPriceItem : CheckedIndicatorItem {
protected override string Name { get { return "Median Price"; } }
protected override Indicator CreateIndicator() {
return new MedianPrice();
}
}
public class TypicalPriceItem : CheckedIndicatorItem {
protected override string Name { get { return "Typical Price"; } }
protected override Indicator CreateIndicator() {
return new TypicalPrice();
}
}
public class WeightedCloseItem : CheckedIndicatorItem {
protected override string Name { get { return "Weighted Close"; } }
protected override Indicator CreateIndicator() {
return new WeightedClose();
}
}
public class AverageTrueRangeItem : CheckedIndicatorItem {
protected override string Name { get { return "Average True Range"; } }
protected override Indicator CreateIndicator() {
return new AverageTrueRange();
}
}
public class CommodityChannelIndexItem : CheckedIndicatorItem {
protected override string Name { get { return "Commodity Channel Index"; } }
protected override Indicator CreateIndicator() {
return new CommodityChannelIndex();
}
}
public class DetrendedPriceOscillatorItem : CheckedIndicatorItem {
protected override string Name { get { return "Detrended Price Oscillator"; } }
protected override Indicator CreateIndicator() {
return new DetrendedPriceOscillator();
}
}
public class MassIndexItem : CheckedIndicatorItem {
protected override string Name { get { return "Mass Index"; } }
protected override Indicator CreateIndicator() {
return new MassIndex();
}
}
public class MovingAverageConvergenceDivergenceItem : CheckedIndicatorItem {
protected override string Name { get { return "Moving Average Convergence Divergence"; } }
protected override Indicator CreateIndicator() {
return new MovingAverageConvergenceDivergence();
}
}
public class RateOfChangeItem : CheckedIndicatorItem {
protected override string Name { get { return "Rate Of Change"; } }
protected override Indicator CreateIndicator() {
return new RateOfChange();
}
}
public class RelativeStrengthIndexItem : CheckedIndicatorItem {
protected override string Name { get { return "Relative Strength Index"; } }
protected override Indicator CreateIndicator() {
return new RelativeStrengthIndex();
}
}
public class StandardDeviationItem : CheckedIndicatorItem {
protected override string Name { get { return "Standard Deviation"; } }
protected override Indicator CreateIndicator() {
return new StandardDeviation();
}
}
public class ChaikinsVolatilityItem : CheckedIndicatorItem {
protected override string Name { get { return "Chaikins Volatility"; } }
protected override Indicator CreateIndicator() {
return new ChaikinsVolatility();
}
}
public class WilliamsRItem : CheckedIndicatorItem {
protected override string Name { get { return "Williams %R"; } }
protected override Indicator CreateIndicator() {
return new WilliamsR();
}
}
}

View File

@@ -0,0 +1,68 @@
using System.Collections.Generic;
using DevExpress.XtraCharts;
using DevExpress.XtraCharts.Native;
namespace DevExpress.StockMarketTrader {
public static class ChartHelper {
static void InitializeNewPaneLegend(ChartControl chart, SeparatePaneIndicator indicator) {
Legend legend = new Legend();
chart.Legends.Add(legend);
indicator.Legend = legend;
legend.Tag = indicator.Tag;
legend.DockTarget = indicator.Pane;
legend.AlignmentHorizontal = LegendAlignmentHorizontal.Left;
legend.Margins.All = chart.Legend.Margins.All;
}
static void UpdateAxisXVisibilityInPanes(XYDiagram diagram) {
List<XYDiagramPaneBase> panes = diagram.GetAllPanes();
for (int i = 0; i < panes.Count; i++)
diagram.AxisX.SetVisibilityInPane(i == panes.Count - 1, panes[i]);
}
public static void InitializeSeparatePaneIndicator(ChartControl chart, SeparatePaneIndicator separatePaneIndicator) {
XYDiagram diagram = chart.Diagram as XYDiagram;
if (diagram != null) {
XYDiagramPane pane = new XYDiagramPane(separatePaneIndicator.Name + " Pane");
pane.Tag = separatePaneIndicator.Tag;
diagram.Panes.Add(pane);
SecondaryAxisY axisY = new SecondaryAxisY(separatePaneIndicator.Name + " Axis");
axisY.Tag = separatePaneIndicator.Tag;
axisY.Alignment = AxisAlignment.Far;
axisY.GridLines.Visible = true;
axisY.GridLines.MinorVisible = true;
axisY.WholeRange.AlwaysShowZeroLevel = false;
diagram.SecondaryAxesY.Add(axisY);
separatePaneIndicator.Pane = pane;
separatePaneIndicator.AxisY = axisY;
InitializeNewPaneLegend(chart, separatePaneIndicator);
UpdateAxisXVisibilityInPanes(diagram);
}
}
public static void RemoveIndicator(ChartControl chart, XYDiagramSeriesViewBase view, Indicator indicator) {
SeparatePaneIndicator separatePaneIndicator = indicator as SeparatePaneIndicator;
if (separatePaneIndicator != null ) {
foreach (Legend legend in chart.Legends) {
if (legend.Tag == separatePaneIndicator.Tag) {
chart.Legends.Remove(legend);
break;
}
}
XYDiagram diagram = chart.Diagram as XYDiagram;
if (diagram != null) {
foreach (XYDiagramPane pane in diagram.Panes) {
if (pane.Tag == separatePaneIndicator.Tag) {
diagram.Panes.Remove(pane);
break;
}
}
foreach (SecondaryAxisY axisY in diagram.SecondaryAxesY) {
if (axisY.Tag == separatePaneIndicator.Tag) {
diagram.SecondaryAxesY.Remove(axisY);
break;
}
}
}
}
view.Indicators.Remove(indicator);
}
}
}

View File

@@ -0,0 +1,44 @@
using DevExpress.XtraCharts;
namespace DevExpress.StockMarketTrader {
public abstract class IndicatorItem {
protected abstract string Name { get; }
protected abstract Indicator CreateIndicator();
public override string ToString() {
return Name;
}
}
public abstract class CheckedIndicatorItem : IndicatorItem {
bool indicatorVisible;
protected virtual string IndicatorName { get { return Name; } }
public void UpdateIndicator(ChartControl chart, XYDiagramSeriesViewBase seriesView, bool indicatorVisible) {
if (this.indicatorVisible != indicatorVisible) {
if (indicatorVisible) {
Indicator indicator = CreateIndicator();
if (indicator != null) {
indicator.Tag = GetHashCode();
indicator.Name = IndicatorName;
indicator.ShowInLegend = true;
seriesView.Indicators.Add(indicator);
if (indicator is SeparatePaneIndicator)
ChartHelper.InitializeSeparatePaneIndicator(chart, (SeparatePaneIndicator)indicator);
}
}
else {
int tag = GetHashCode();
foreach (Indicator indicator in seriesView.Indicators) {
if (indicator.Tag is int && (int)indicator.Tag == tag) {
ChartHelper.RemoveIndicator(chart, seriesView, indicator);
break;
}
}
}
this.indicatorVisible = indicatorVisible;
}
}
}
}

View File

@@ -0,0 +1,54 @@
using DevExpress.XtraCharts;
namespace DevExpress.StockMarketTrader {
public abstract class MovingAverageItem : CheckedIndicatorItem {
protected override string Name { get { return IndicatorName + " Moving Average"; } }
protected abstract MovingAverage CreateMovingAverage();
protected override Indicator CreateIndicator() {
MovingAverage movingAverage = CreateMovingAverage();
movingAverage.ValueLevel = ValueLevel.Close;
return movingAverage;
}
}
public class SimpleMovingAverageItem : MovingAverageItem {
protected override string IndicatorName { get { return "Simple"; } }
protected override MovingAverage CreateMovingAverage() {
return new SimpleMovingAverage();
}
}
public class ExponentialMovingAverageItem : MovingAverageItem {
protected override string IndicatorName { get { return "Exponential"; } }
protected override MovingAverage CreateMovingAverage() {
return new ExponentialMovingAverage();
}
}
public class TripleExponentialMovingAverageItem : MovingAverageItem {
protected override string IndicatorName { get { return "Triple Exponential"; } }
protected override MovingAverage CreateMovingAverage() {
return new TripleExponentialMovingAverageTema();
}
}
public class TriangularMovingAverageItem : MovingAverageItem {
protected override string IndicatorName { get { return "Triangular"; } }
protected override MovingAverage CreateMovingAverage() {
return new TriangularMovingAverage();
}
}
public class WeightedMovingAverageItem : MovingAverageItem {
protected override string IndicatorName { get { return "Weighted"; } }
protected override MovingAverage CreateMovingAverage() {
return new WeightedMovingAverage();
}
}
}

View File

@@ -0,0 +1,15 @@
using DevExpress.XtraCharts;
namespace DevExpress.StockMarketTrader {
public abstract class RegressionItem : CheckedIndicatorItem {
protected override string Name { get { return IndicatorName + " Regression"; } }
}
public class LinearRegressionItem : RegressionItem {
protected override string IndicatorName { get { return "Linear"; } }
protected override Indicator CreateIndicator() {
return new RegressionLine();
}
}
}

View File

@@ -0,0 +1,606 @@
namespace DevExpress.StockMarketTrader {
partial class StockChartUC {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if(disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
DevExpress.Utils.SuperToolTip superToolTip1 = new DevExpress.Utils.SuperToolTip();
DevExpress.Utils.ToolTipTitleItem toolTipTitleItem1 = new DevExpress.Utils.ToolTipTitleItem();
DevExpress.Utils.ToolTipItem toolTipItem1 = new DevExpress.Utils.ToolTipItem();
DevExpress.Utils.SuperToolTip superToolTip2 = new DevExpress.Utils.SuperToolTip();
DevExpress.Utils.ToolTipTitleItem toolTipTitleItem2 = new DevExpress.Utils.ToolTipTitleItem();
DevExpress.Utils.ToolTipItem toolTipItem2 = new DevExpress.Utils.ToolTipItem();
DevExpress.Utils.SuperToolTip superToolTip3 = new DevExpress.Utils.SuperToolTip();
DevExpress.Utils.ToolTipTitleItem toolTipTitleItem3 = new DevExpress.Utils.ToolTipTitleItem();
DevExpress.Utils.ToolTipItem toolTipItem3 = new DevExpress.Utils.ToolTipItem();
DevExpress.Utils.SuperToolTip superToolTip4 = new DevExpress.Utils.SuperToolTip();
DevExpress.Utils.ToolTipTitleItem toolTipTitleItem4 = new DevExpress.Utils.ToolTipTitleItem();
DevExpress.Utils.ToolTipItem toolTipItem4 = new DevExpress.Utils.ToolTipItem();
DevExpress.Utils.SuperToolTip superToolTip5 = new DevExpress.Utils.SuperToolTip();
DevExpress.Utils.ToolTipTitleItem toolTipTitleItem5 = new DevExpress.Utils.ToolTipTitleItem();
DevExpress.Utils.ToolTipItem toolTipItem5 = new DevExpress.Utils.ToolTipItem();
DevExpress.Utils.SuperToolTip superToolTip6 = new DevExpress.Utils.SuperToolTip();
DevExpress.Utils.ToolTipTitleItem toolTipTitleItem6 = new DevExpress.Utils.ToolTipTitleItem();
DevExpress.Utils.ToolTipItem toolTipItem6 = new DevExpress.Utils.ToolTipItem();
DevExpress.Utils.SuperToolTip superToolTip7 = new DevExpress.Utils.SuperToolTip();
DevExpress.Utils.ToolTipTitleItem toolTipTitleItem7 = new DevExpress.Utils.ToolTipTitleItem();
DevExpress.Utils.ToolTipItem toolTipItem7 = new DevExpress.Utils.ToolTipItem();
DevExpress.XtraCharts.XYDiagram xyDiagram1 = new DevExpress.XtraCharts.XYDiagram();
DevExpress.XtraCharts.CustomAxisLabel customAxisLabel1 = new DevExpress.XtraCharts.CustomAxisLabel();
DevExpress.XtraCharts.XYDiagramPane xyDiagramPane1 = new DevExpress.XtraCharts.XYDiagramPane();
DevExpress.XtraCharts.SecondaryAxisY secondaryAxisY1 = new DevExpress.XtraCharts.SecondaryAxisY();
DevExpress.XtraCharts.Legend legend1 = new DevExpress.XtraCharts.Legend();
DevExpress.XtraCharts.Series series1 = new DevExpress.XtraCharts.Series();
DevExpress.XtraCharts.CandleStickSeriesView candleStickSeriesView1 = new DevExpress.XtraCharts.CandleStickSeriesView();
DevExpress.XtraCharts.Series series2 = new DevExpress.XtraCharts.Series();
DevExpress.XtraCharts.SideBySideBarSeriesLabel sideBySideBarSeriesLabel1 = new DevExpress.XtraCharts.SideBySideBarSeriesLabel();
DevExpress.XtraCharts.SideBySideBarSeriesView sideBySideBarSeriesView1 = new DevExpress.XtraCharts.SideBySideBarSeriesView();
DevExpress.XtraCharts.CandleStickSeriesView candleStickSeriesView2 = new DevExpress.XtraCharts.CandleStickSeriesView();
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
this.barMain = new DevExpress.XtraBars.Bar();
this.stockBarCheckItem = new DevExpress.XtraBars.BarCheckItem();
this.candleStickBarCheckItem = new DevExpress.XtraBars.BarCheckItem();
this.volumesBarCheckItem = new DevExpress.XtraBars.BarCheckItem();
this.barCheckItem3 = new DevExpress.XtraBars.BarCheckItem();
this.barCheckItem4 = new DevExpress.XtraBars.BarCheckItem();
this.barCheckItem5 = new DevExpress.XtraBars.BarCheckItem();
this.barCheckItem6 = new DevExpress.XtraBars.BarCheckItem();
this.barCheckItem7 = new DevExpress.XtraBars.BarCheckItem();
this.barStaticItemPeriod = new DevExpress.XtraBars.BarStaticItem();
this.comboBoxBarEditItem = new DevExpress.XtraBars.BarEditItem();
this.repositoryItemComboBoxPeriod = new DevExpress.XtraEditors.Repository.RepositoryItemComboBox();
this.barCheckItemTrendLine = new DevExpress.XtraBars.BarCheckItem();
this.barCheckItemFibonacciArcs = new DevExpress.XtraBars.BarCheckItem();
this.barCheckItemFibonacciFans = new DevExpress.XtraBars.BarCheckItem();
this.barCheckItemFibonacciRetracement = new DevExpress.XtraBars.BarCheckItem();
this.barCheckItemRemoveIndicator = new DevExpress.XtraBars.BarCheckItem();
this.barStaticItemAdvancedIndicators = new DevExpress.XtraBars.BarStaticItem();
this.barEditItemAdvancedIndicators = new DevExpress.XtraBars.BarEditItem();
this.repositoryItemCheckedComboBoxEditAdvancedIndicators = new DevExpress.XtraEditors.Repository.RepositoryItemCheckedComboBoxEdit();
this.barAndDockingController1 = new DevExpress.XtraBars.BarAndDockingController(this.components);
this.barDockControlTop = new DevExpress.XtraBars.BarDockControl();
this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl();
this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl();
this.barDockControlRight = new DevExpress.XtraBars.BarDockControl();
this.barCheckItemRegressionLine = new DevExpress.XtraBars.BarCheckItem();
this.repositoryItemCheckedComboBoxEditMovingAverages = new DevExpress.XtraEditors.Repository.RepositoryItemCheckedComboBoxEdit();
this.repositoryItemComboBoxRegression = new DevExpress.XtraEditors.Repository.RepositoryItemComboBox();
this.stockChart = new DevExpress.XtraCharts.ChartControl();
this.barCheckItem1 = new DevExpress.XtraBars.BarCheckItem();
((System.ComponentModel.ISupportInitialize)(this.barManager1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemComboBoxPeriod)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemCheckedComboBoxEditAdvancedIndicators)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.barAndDockingController1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemCheckedComboBoxEditMovingAverages)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemComboBoxRegression)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.stockChart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(xyDiagram1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(xyDiagramPane1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(secondaryAxisY1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(series1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(candleStickSeriesView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(series2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(sideBySideBarSeriesLabel1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(sideBySideBarSeriesView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(candleStickSeriesView2)).BeginInit();
this.SuspendLayout();
//
// barManager1
//
this.barManager1.Bars.AddRange(new DevExpress.XtraBars.Bar[] {
this.barMain});
this.barManager1.Controller = this.barAndDockingController1;
this.barManager1.DockControls.Add(this.barDockControlTop);
this.barManager1.DockControls.Add(this.barDockControlBottom);
this.barManager1.DockControls.Add(this.barDockControlLeft);
this.barManager1.DockControls.Add(this.barDockControlRight);
this.barManager1.Form = this;
this.barManager1.Items.AddRange(new DevExpress.XtraBars.BarItem[] {
this.stockBarCheckItem,
this.candleStickBarCheckItem,
this.volumesBarCheckItem,
this.barCheckItem3,
this.barCheckItem4,
this.barCheckItem5,
this.barCheckItem6,
this.barCheckItem7,
this.barStaticItemPeriod,
this.comboBoxBarEditItem,
this.barCheckItemTrendLine,
this.barCheckItemFibonacciArcs,
this.barCheckItemFibonacciFans,
this.barCheckItemFibonacciRetracement,
this.barCheckItemRemoveIndicator,
this.barCheckItemRegressionLine,
this.barStaticItemAdvancedIndicators,
this.barEditItemAdvancedIndicators});
this.barManager1.MaxItemId = 37;
this.barManager1.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
this.repositoryItemComboBoxPeriod,
this.repositoryItemCheckedComboBoxEditMovingAverages,
this.repositoryItemComboBoxRegression,
this.repositoryItemCheckedComboBoxEditAdvancedIndicators});
//
// barMain
//
this.barMain.BarName = "Main";
this.barMain.DockCol = 0;
this.barMain.DockRow = 0;
this.barMain.DockStyle = DevExpress.XtraBars.BarDockStyle.Top;
this.barMain.LinksPersistInfo.AddRange(new DevExpress.XtraBars.LinkPersistInfo[] {
new DevExpress.XtraBars.LinkPersistInfo(this.stockBarCheckItem, true),
new DevExpress.XtraBars.LinkPersistInfo(this.candleStickBarCheckItem),
new DevExpress.XtraBars.LinkPersistInfo(this.volumesBarCheckItem),
new DevExpress.XtraBars.LinkPersistInfo(this.barCheckItem3, true),
new DevExpress.XtraBars.LinkPersistInfo(this.barCheckItem4),
new DevExpress.XtraBars.LinkPersistInfo(this.barCheckItem5),
new DevExpress.XtraBars.LinkPersistInfo(this.barCheckItem6),
new DevExpress.XtraBars.LinkPersistInfo(this.barCheckItem7),
new DevExpress.XtraBars.LinkPersistInfo(((DevExpress.XtraBars.BarLinkUserDefines)((DevExpress.XtraBars.BarLinkUserDefines.Caption | DevExpress.XtraBars.BarLinkUserDefines.PaintStyle))), this.barStaticItemPeriod, "Period:", true, true, true, 0, null, DevExpress.XtraBars.BarItemPaintStyle.Caption),
new DevExpress.XtraBars.LinkPersistInfo(DevExpress.XtraBars.BarLinkUserDefines.Width, this.comboBoxBarEditItem, "", false, true, true, 79),
new DevExpress.XtraBars.LinkPersistInfo(this.barCheckItemTrendLine, true),
new DevExpress.XtraBars.LinkPersistInfo(this.barCheckItemFibonacciArcs),
new DevExpress.XtraBars.LinkPersistInfo(this.barCheckItemFibonacciFans),
new DevExpress.XtraBars.LinkPersistInfo(this.barCheckItemFibonacciRetracement),
new DevExpress.XtraBars.LinkPersistInfo(this.barCheckItemRemoveIndicator),
new DevExpress.XtraBars.LinkPersistInfo(this.barStaticItemAdvancedIndicators, true),
new DevExpress.XtraBars.LinkPersistInfo(this.barEditItemAdvancedIndicators)});
this.barMain.OptionsBar.AllowQuickCustomization = false;
this.barMain.OptionsBar.DrawBorder = false;
this.barMain.OptionsBar.DrawDragBorder = false;
this.barMain.OptionsBar.UseWholeRow = true;
this.barMain.Text = "Main";
//
// stockBarCheckItem
//
this.stockBarCheckItem.Caption = "Stock";
this.stockBarCheckItem.GroupIndex = 2;
this.stockBarCheckItem.Id = 16;
this.stockBarCheckItem.Name = "stockBarCheckItem";
this.stockBarCheckItem.CheckedChanged += new DevExpress.XtraBars.ItemClickEventHandler(this.ChangeViewToStock);
//
// candleStickBarCheckItem
//
this.candleStickBarCheckItem.BindableChecked = true;
this.candleStickBarCheckItem.Caption = "Candle Stick";
this.candleStickBarCheckItem.Checked = true;
this.candleStickBarCheckItem.GroupIndex = 2;
this.candleStickBarCheckItem.Id = 15;
this.candleStickBarCheckItem.Name = "candleStickBarCheckItem";
this.candleStickBarCheckItem.CheckedChanged += new DevExpress.XtraBars.ItemClickEventHandler(this.ChangeViewToCandleStick);
//
// volumesBarCheckItem
//
this.volumesBarCheckItem.BindableChecked = true;
this.volumesBarCheckItem.Caption = "Volume";
this.volumesBarCheckItem.Checked = true;
this.volumesBarCheckItem.Id = 2;
this.volumesBarCheckItem.Name = "volumesBarCheckItem";
this.volumesBarCheckItem.CheckedChanged += new DevExpress.XtraBars.ItemClickEventHandler(this.OnShowVolumeChartChanged);
//
// barCheckItem3
//
this.barCheckItem3.Caption = "6m";
this.barCheckItem3.GroupIndex = 1;
this.barCheckItem3.Id = 4;
this.barCheckItem3.Name = "barCheckItem3";
this.barCheckItem3.Tag = 120;
this.barCheckItem3.CheckedChanged += new DevExpress.XtraBars.ItemClickEventHandler(this.OnPeriodChanged);
//
// barCheckItem4
//
this.barCheckItem4.Caption = "1y";
this.barCheckItem4.GroupIndex = 1;
this.barCheckItem4.Id = 5;
this.barCheckItem4.Name = "barCheckItem4";
this.barCheckItem4.Tag = 240;
this.barCheckItem4.CheckedChanged += new DevExpress.XtraBars.ItemClickEventHandler(this.OnPeriodChanged);
//
// barCheckItem5
//
this.barCheckItem5.BindableChecked = true;
this.barCheckItem5.Caption = "1.5y";
this.barCheckItem5.GroupIndex = 1;
this.barCheckItem5.Id = 6;
this.barCheckItem5.Name = "barCheckItem5";
this.barCheckItem5.Tag = 360;
this.barCheckItem5.CheckedChanged += new DevExpress.XtraBars.ItemClickEventHandler(this.OnPeriodChanged);
//
// barCheckItem6
//
this.barCheckItem6.Caption = "2y";
this.barCheckItem6.GroupIndex = 1;
this.barCheckItem6.Id = 7;
this.barCheckItem6.Name = "barCheckItem6";
this.barCheckItem6.Tag = 480;
this.barCheckItem6.CheckedChanged += new DevExpress.XtraBars.ItemClickEventHandler(this.OnPeriodChanged);
//
// barCheckItem7
//
this.barCheckItem7.Caption = "4y";
this.barCheckItem7.GroupIndex = 1;
this.barCheckItem7.Checked = true;
this.barCheckItem7.Id = 8;
this.barCheckItem7.Name = "barCheckItem7";
this.barCheckItem7.Tag = 960;
this.barCheckItem7.CheckedChanged += new DevExpress.XtraBars.ItemClickEventHandler(this.OnPeriodChanged);
//
// barStaticItemPeriod
//
this.barStaticItemPeriod.Caption = "Period:";
this.barStaticItemPeriod.Id = 9;
this.barStaticItemPeriod.Name = "barStaticItemPeriod";
//
// comboBoxBarEditItem
//
this.comboBoxBarEditItem.Caption = "Period";
this.comboBoxBarEditItem.Edit = this.repositoryItemComboBoxPeriod;
this.comboBoxBarEditItem.EditWidth = 65;
this.comboBoxBarEditItem.Id = 13;
this.comboBoxBarEditItem.Name = "comboBoxBarEditItem";
this.comboBoxBarEditItem.EditValueChanged += new System.EventHandler(this.OnTicksChanged);
//
// repositoryItemComboBoxPeriod
//
this.repositoryItemComboBoxPeriod.AutoHeight = false;
this.repositoryItemComboBoxPeriod.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.repositoryItemComboBoxPeriod.Name = "repositoryItemComboBoxPeriod";
this.repositoryItemComboBoxPeriod.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
//
// barCheckItemTrendLine
//
this.barCheckItemTrendLine.Caption = "Trend Line";
this.barCheckItemTrendLine.Id = 19;
this.barCheckItemTrendLine.Name = "barCheckItemTrendLine";
toolTipTitleItem1.Text = "Trend Line";
toolTipItem1.LeftIndent = 6;
toolTipItem1.Text = "To add a Trend Line, click on the first series point and drag mouse to the secon" +
"d series point.";
superToolTip1.Items.Add(toolTipTitleItem1);
superToolTip1.Items.Add(toolTipItem1);
this.barCheckItemTrendLine.SuperTip = superToolTip1;
this.barCheckItemTrendLine.CheckedChanged += new DevExpress.XtraBars.ItemClickEventHandler(this.UpdateDrawingItems);
//
// barCheckItemFibonacciArcs
//
this.barCheckItemFibonacciArcs.Caption = "Fibonacci Arcs";
this.barCheckItemFibonacciArcs.Id = 20;
this.barCheckItemFibonacciArcs.Name = "barCheckItemFibonacciArcs";
toolTipTitleItem2.Text = "Fibonacci Arcs";
toolTipItem2.LeftIndent = 6;
toolTipItem2.Text = "To add a Fibonacci Arcs, click on the first series point and drag mouse to the s" +
"econd series point.";
superToolTip2.Items.Add(toolTipTitleItem2);
superToolTip2.Items.Add(toolTipItem2);
this.barCheckItemFibonacciArcs.SuperTip = superToolTip2;
this.barCheckItemFibonacciArcs.CheckedChanged += new DevExpress.XtraBars.ItemClickEventHandler(this.UpdateDrawingItems);
//
// barCheckItemFibonacciFans
//
this.barCheckItemFibonacciFans.Caption = "Fibonacci Fans";
this.barCheckItemFibonacciFans.Id = 21;
this.barCheckItemFibonacciFans.Name = "barCheckItemFibonacciFans";
toolTipTitleItem3.Text = "Fibonacci Fans";
toolTipItem3.LeftIndent = 6;
toolTipItem3.Text = "To add a Fibonacci Fans, click on the first series point and drag mouse to the s" +
"econd series point.";
superToolTip3.Items.Add(toolTipTitleItem3);
superToolTip3.Items.Add(toolTipItem3);
this.barCheckItemFibonacciFans.SuperTip = superToolTip3;
this.barCheckItemFibonacciFans.CheckedChanged += new DevExpress.XtraBars.ItemClickEventHandler(this.UpdateDrawingItems);
//
// barCheckItemFibonacciRetracement
//
this.barCheckItemFibonacciRetracement.Caption = "Fibonacci Retracement";
this.barCheckItemFibonacciRetracement.Id = 22;
this.barCheckItemFibonacciRetracement.Name = "barCheckItemFibonacciRetracement";
toolTipTitleItem4.Text = "Fibonacci Retracement";
toolTipItem4.LeftIndent = 6;
toolTipItem4.Text = "To add a Fibonacci Retracement, click on the first series point and drag mouse t" +
"o the second series point.";
superToolTip4.Items.Add(toolTipTitleItem4);
superToolTip4.Items.Add(toolTipItem4);
this.barCheckItemFibonacciRetracement.SuperTip = superToolTip4;
this.barCheckItemFibonacciRetracement.CheckedChanged += new DevExpress.XtraBars.ItemClickEventHandler(this.UpdateDrawingItems);
//
// barCheckItemRemoveIndicator
//
this.barCheckItemRemoveIndicator.Caption = "Remove Indicator";
this.barCheckItemRemoveIndicator.Id = 27;
this.barCheckItemRemoveIndicator.Name = "barCheckItemRemoveIndicator";
toolTipTitleItem5.Text = "Remove Indicator";
toolTipItem5.LeftIndent = 6;
toolTipItem5.Text = "To remove an indicator, click it or its label.";
superToolTip5.Items.Add(toolTipTitleItem5);
superToolTip5.Items.Add(toolTipItem5);
this.barCheckItemRemoveIndicator.SuperTip = superToolTip5;
this.barCheckItemRemoveIndicator.CheckedChanged += new DevExpress.XtraBars.ItemClickEventHandler(this.barCheckItemRemoveIndicator_CheckedChanged);
//
// barStaticItemAdvancedIndicators
//
this.barStaticItemAdvancedIndicators.Border = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.barStaticItemAdvancedIndicators.Caption = "Indicators:";
this.barStaticItemAdvancedIndicators.Id = 35;
this.barStaticItemAdvancedIndicators.Name = "barStaticItemAdvancedIndicators";
toolTipTitleItem6.Text = "Advanced Indicators";
toolTipItem6.LeftIndent = 6;
toolTipItem6.Text = "To add an indicator, check it in a drop down list.";
superToolTip6.Items.Add(toolTipTitleItem6);
superToolTip6.Items.Add(toolTipItem6);
this.barStaticItemAdvancedIndicators.SuperTip = superToolTip6;
//
// barEditItemAdvancedIndicators
//
this.barEditItemAdvancedIndicators.Caption = "Advanced Indicators";
this.barEditItemAdvancedIndicators.Edit = this.repositoryItemCheckedComboBoxEditAdvancedIndicators;
this.barEditItemAdvancedIndicators.EditWidth = 80;
this.barEditItemAdvancedIndicators.Id = 36;
this.barEditItemAdvancedIndicators.Name = "barEditItemAdvancedIndicators";
toolTipTitleItem7.Text = "Advanced Indicators";
toolTipItem7.LeftIndent = 6;
toolTipItem7.Text = "To add an indicator, check it in a drop down list.";
superToolTip7.Items.Add(toolTipTitleItem7);
superToolTip7.Items.Add(toolTipItem7);
this.barEditItemAdvancedIndicators.SuperTip = superToolTip7;
this.barEditItemAdvancedIndicators.EditValueChanged += new System.EventHandler(this.barEditItemAdvancedIndicators_EditValueChanged);
//
// repositoryItemCheckedComboBoxEditAdvancedIndicators
//
this.repositoryItemCheckedComboBoxEditAdvancedIndicators.AutoHeight = false;
this.repositoryItemCheckedComboBoxEditAdvancedIndicators.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.repositoryItemCheckedComboBoxEditAdvancedIndicators.Name = "repositoryItemCheckedComboBoxEditAdvancedIndicators";
this.repositoryItemCheckedComboBoxEditAdvancedIndicators.PopupFormSize = new System.Drawing.Size(240, 410);
this.repositoryItemCheckedComboBoxEditAdvancedIndicators.SelectAllItemVisible = false;
//
// barAndDockingController1
//
this.barAndDockingController1.PropertiesBar.AllowLinkLighting = false;
this.barAndDockingController1.PropertiesDocking.ViewStyle = DevExpress.XtraBars.Docking2010.Views.DockingViewStyle.Classic;
//
// barDockControlTop
//
this.barDockControlTop.CausesValidation = false;
this.barDockControlTop.Dock = System.Windows.Forms.DockStyle.Top;
this.barDockControlTop.Location = new System.Drawing.Point(0, 0);
this.barDockControlTop.Manager = this.barManager1;
this.barDockControlTop.Size = new System.Drawing.Size(1157, 20);
//
// barDockControlBottom
//
this.barDockControlBottom.CausesValidation = false;
this.barDockControlBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
this.barDockControlBottom.Location = new System.Drawing.Point(0, 536);
this.barDockControlBottom.Manager = this.barManager1;
this.barDockControlBottom.Size = new System.Drawing.Size(1157, 0);
//
// barDockControlLeft
//
this.barDockControlLeft.CausesValidation = false;
this.barDockControlLeft.Dock = System.Windows.Forms.DockStyle.Left;
this.barDockControlLeft.Location = new System.Drawing.Point(0, 20);
this.barDockControlLeft.Manager = this.barManager1;
this.barDockControlLeft.Size = new System.Drawing.Size(0, 516);
//
// barDockControlRight
//
this.barDockControlRight.CausesValidation = false;
this.barDockControlRight.Dock = System.Windows.Forms.DockStyle.Right;
this.barDockControlRight.Location = new System.Drawing.Point(1157, 20);
this.barDockControlRight.Manager = this.barManager1;
this.barDockControlRight.Size = new System.Drawing.Size(0, 516);
//
// barCheckItemRegressionLine
//
this.barCheckItemRegressionLine.Caption = "Regression Line";
this.barCheckItemRegressionLine.Id = 28;
this.barCheckItemRegressionLine.Name = "barCheckItemRegressionLine";
//
// repositoryItemCheckedComboBoxEditMovingAverages
//
this.repositoryItemCheckedComboBoxEditMovingAverages.AutoHeight = false;
this.repositoryItemCheckedComboBoxEditMovingAverages.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.repositoryItemCheckedComboBoxEditMovingAverages.Name = "repositoryItemCheckedComboBoxEditMovingAverages";
this.repositoryItemCheckedComboBoxEditMovingAverages.SelectAllItemVisible = false;
//
// repositoryItemComboBoxRegression
//
this.repositoryItemComboBoxRegression.AutoHeight = false;
this.repositoryItemComboBoxRegression.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.repositoryItemComboBoxRegression.Name = "repositoryItemComboBoxRegression";
this.repositoryItemComboBoxRegression.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
//
// stockChart
//
this.stockChart.AccessibleRole = System.Windows.Forms.AccessibleRole.Application;
this.stockChart.AutoLayout = false;
this.stockChart.BorderOptions.Visibility = DevExpress.Utils.DefaultBoolean.False;
//this.stockChart.CrosshairOptions.ArgumentLineColor = System.Drawing.Color.White;
this.stockChart.CrosshairOptions.ShowOnlyInFocusedPane = false;
//this.stockChart.CrosshairOptions.ValueLineColor = System.Drawing.Color.White;
xyDiagram1.AxisX.DateTimeScaleOptions.MeasureUnit = DevExpress.XtraCharts.DateTimeMeasureUnit.Week;
xyDiagram1.AxisX.GridLines.MinorVisible = true;
xyDiagram1.AxisX.GridLines.Visible = true;
xyDiagram1.AxisX.VisibleInPanesSerializable = "0";
xyDiagram1.AxisY.Alignment = DevExpress.XtraCharts.AxisAlignment.Far;
customAxisLabel1.AxisValueSerializable = "1";
customAxisLabel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(71)))), ((int)(((byte)(71)))), ((int)(((byte)(71)))));
customAxisLabel1.Name = "$1,0";
//customAxisLabel1.TextColor = System.Drawing.Color.White;
xyDiagram1.AxisY.CustomLabels.AddRange(new DevExpress.XtraCharts.CustomAxisLabel[] {
customAxisLabel1});
xyDiagram1.AxisY.GridLines.MinorVisible = true;
xyDiagram1.AxisY.Label.ResolveOverlappingOptions.AllowHide = false;
xyDiagram1.AxisY.Label.ResolveOverlappingOptions.AllowRotate = false;
xyDiagram1.AxisY.Label.ResolveOverlappingOptions.AllowStagger = false;
xyDiagram1.AxisY.Label.TextPattern = "${V:F1}";
xyDiagram1.AxisY.LabelVisibilityMode = DevExpress.XtraCharts.AxisLabelVisibilityMode.AutoGeneratedAndCustom;
xyDiagram1.AxisY.Title.Text = "";
xyDiagram1.AxisY.VisibleInPanesSerializable = "-1";
xyDiagram1.AxisY.WholeRange.AlwaysShowZeroLevel = false;
xyDiagram1.DefaultPane.LayoutOptions.RowSpan = 2;
xyDiagram1.PaneDistance = 5;
xyDiagramPane1.Name = "Volume Pane";
xyDiagramPane1.PaneID = 0;
xyDiagram1.Panes.AddRange(new DevExpress.XtraCharts.XYDiagramPane[] {
xyDiagramPane1});
secondaryAxisY1.AxisID = 1;
secondaryAxisY1.GridLines.MinorVisible = true;
secondaryAxisY1.GridLines.Visible = true;
secondaryAxisY1.Label.TextPattern = "{V:F1}M";
secondaryAxisY1.Name = "Volume Axis";
secondaryAxisY1.VisibleInPanesSerializable = "0";
xyDiagram1.SecondaryAxesY.AddRange(new DevExpress.XtraCharts.SecondaryAxisY[] {
secondaryAxisY1});
this.stockChart.Diagram = xyDiagram1;
this.stockChart.Dock = System.Windows.Forms.DockStyle.Fill;
this.stockChart.Legend.AlignmentHorizontal = DevExpress.XtraCharts.LegendAlignmentHorizontal.Left;
this.stockChart.Legend.Margins.Bottom = 10;
this.stockChart.Legend.Margins.Left = 10;
this.stockChart.Legend.Margins.Right = 10;
this.stockChart.Legend.Margins.Top = 10;
this.stockChart.Legend.Name = "Default Legend";
this.stockChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
legend1.AlignmentHorizontal = DevExpress.XtraCharts.LegendAlignmentHorizontal.Left;
legend1.DockTargetName = "Volume Pane";
legend1.Margins.Bottom = 10;
legend1.Margins.Left = 10;
legend1.Margins.Right = 10;
legend1.Margins.Top = 10;
legend1.Name = "Volume Legend";
this.stockChart.Legends.AddRange(new DevExpress.XtraCharts.Legend[] {
legend1});
this.stockChart.Location = new System.Drawing.Point(0, 20);
this.stockChart.Name = "stockChart";
this.stockChart.SelectionMode = DevExpress.XtraCharts.ElementSelectionMode.Single;
series1.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.DateTime;
series1.Name = "Price";
candleStickSeriesView1.LevelLineLength = 0.3D;
candleStickSeriesView1.LineThickness = 1;
series1.View = candleStickSeriesView1;
series2.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.DateTime;
series2.CrosshairLabelPattern = "{S} : {V}M";
sideBySideBarSeriesLabel1.LineVisibility = DevExpress.Utils.DefaultBoolean.False;
series2.Label = sideBySideBarSeriesLabel1;
series2.LegendName = "Volume Legend";
series2.LegendTextPattern = "{A}";
series2.Name = "Volume";
sideBySideBarSeriesView1.AxisYName = "Volume Axis";
sideBySideBarSeriesView1.BarWidth = 0.8D;
sideBySideBarSeriesView1.PaneName = "Volume Pane";
series2.View = sideBySideBarSeriesView1;
this.stockChart.SeriesSerializable = new DevExpress.XtraCharts.Series[] {
series1,
series2};
this.stockChart.SeriesTemplate.View = candleStickSeriesView2;
this.stockChart.SideBySideBarDistanceFixed = 0;
this.stockChart.Size = new System.Drawing.Size(1157, 516);
this.stockChart.TabIndex = 5;
this.stockChart.ObjectSelected += new DevExpress.XtraCharts.HotTrackEventHandler(this.stockChart_ObjectSelected);
this.stockChart.ObjectHotTracked += new DevExpress.XtraCharts.HotTrackEventHandler(this.stockChart_ObjectHotTracked);
this.stockChart.BoundDataChanged += new DevExpress.XtraCharts.BoundDataChangedEventHandler(this.stockChart_BoundDataChanged);
this.stockChart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.stockChart_MouseDown);
this.stockChart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.stockChart_MouseMove);
this.stockChart.MouseUp += new System.Windows.Forms.MouseEventHandler(this.stockChart_MouseUp);
//
// barCheckItem1
//
this.barCheckItem1.BindableChecked = true;
this.barCheckItem1.Caption = "Crosshair";
this.barCheckItem1.Checked = true;
this.barCheckItem1.GroupIndex = 3;
this.barCheckItem1.Id = 23;
this.barCheckItem1.Name = "barCheckItem1";
//
// StockChartUC
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.stockChart);
this.Controls.Add(this.barDockControlLeft);
this.Controls.Add(this.barDockControlRight);
this.Controls.Add(this.barDockControlBottom);
this.Controls.Add(this.barDockControlTop);
this.Margin = new System.Windows.Forms.Padding(0);
this.Name = "StockChartUC";
this.Size = new System.Drawing.Size(1157, 536);
this.Load += new System.EventHandler(this.StockChartUC_Load);
((System.ComponentModel.ISupportInitialize)(this.barManager1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemComboBoxPeriod)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemCheckedComboBoxEditAdvancedIndicators)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.barAndDockingController1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemCheckedComboBoxEditMovingAverages)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemComboBoxRegression)).EndInit();
((System.ComponentModel.ISupportInitialize)(xyDiagramPane1)).EndInit();
((System.ComponentModel.ISupportInitialize)(secondaryAxisY1)).EndInit();
((System.ComponentModel.ISupportInitialize)(xyDiagram1)).EndInit();
((System.ComponentModel.ISupportInitialize)(candleStickSeriesView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(series1)).EndInit();
((System.ComponentModel.ISupportInitialize)(sideBySideBarSeriesLabel1)).EndInit();
((System.ComponentModel.ISupportInitialize)(sideBySideBarSeriesView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(series2)).EndInit();
((System.ComponentModel.ISupportInitialize)(candleStickSeriesView2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.stockChart)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private XtraBars.BarManager barManager1;
private XtraBars.Bar barMain;
private XtraBars.BarCheckItem volumesBarCheckItem;
private XtraBars.BarCheckItem barCheckItem3;
private XtraBars.BarCheckItem barCheckItem4;
private XtraBars.BarCheckItem barCheckItem5;
private XtraBars.BarCheckItem barCheckItem6;
private XtraBars.BarCheckItem barCheckItem7;
private XtraBars.BarStaticItem barStaticItemPeriod;
private XtraBars.BarDockControl barDockControlTop;
private XtraBars.BarDockControl barDockControlBottom;
private XtraBars.BarDockControl barDockControlLeft;
private XtraBars.BarDockControl barDockControlRight;
public XtraCharts.ChartControl stockChart;
private XtraBars.BarEditItem comboBoxBarEditItem;
private XtraEditors.Repository.RepositoryItemComboBox repositoryItemComboBoxPeriod;
private XtraBars.BarCheckItem stockBarCheckItem;
private XtraBars.BarCheckItem candleStickBarCheckItem;
private XtraBars.BarCheckItem barCheckItemTrendLine;
private XtraBars.BarCheckItem barCheckItemFibonacciArcs;
private XtraBars.BarCheckItem barCheckItemFibonacciFans;
private XtraBars.BarCheckItem barCheckItemFibonacciRetracement;
private XtraBars.BarCheckItem barCheckItemRemoveIndicator;
private XtraBars.BarCheckItem barCheckItem1;
private XtraBars.BarCheckItem barCheckItemRegressionLine;
private XtraEditors.Repository.RepositoryItemCheckedComboBoxEdit repositoryItemCheckedComboBoxEditMovingAverages;
private XtraBars.BarAndDockingController barAndDockingController1;
private XtraEditors.Repository.RepositoryItemComboBox repositoryItemComboBoxRegression;
private XtraBars.BarStaticItem barStaticItemAdvancedIndicators;
private XtraBars.BarEditItem barEditItemAdvancedIndicators;
private XtraEditors.Repository.RepositoryItemCheckedComboBoxEdit repositoryItemCheckedComboBoxEditAdvancedIndicators;
}
}

View File

@@ -0,0 +1,296 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using DevExpress.Utils;
using DevExpress.Utils.Drawing;
using DevExpress.Utils.Svg;
using DevExpress.XtraBars;
using DevExpress.XtraCharts;
using DevExpress.XtraEditors.Controls;
namespace DevExpress.StockMarketTrader {
public partial class StockChartUC : UserControl {
const string PriceSeriesName = "Price";
const string VolumeSeriesName = "Volume";
const int MinCandleCount = 20;
readonly List<PeriodItem> periods = new List<PeriodItem>() { new PeriodItem("1 Week", 5), new PeriodItem("2 Week", 10), new PeriodItem("1 Month", 20) };
bool isSelection = false;
bool isDrawing = false;
int daysCount = 105;
FinancialIndicator draggingIndicator;
ConstantLine trendlineBorder;
XYDiagram Diagram { get { return (XYDiagram)stockChart.Diagram; } }
Series PriceSeries { get { return stockChart.Series[PriceSeriesName]; } }
FinancialSeriesViewBase PriceSeriesView { get { return (FinancialSeriesViewBase)PriceSeries.View; } }
SideBySideBarSeriesView VolumeSeriesView { get { return (SideBySideBarSeriesView)stockChart.Series[VolumeSeriesName].View; } }
public StockChartUC() {
InitializeComponent();
InitializeAdvancedIndicators();
barStaticItemAdvancedIndicators.LeftIndent = 11;
barStaticItemPeriod.LeftIndent = 11;
this.stockChart.LookAndFeel.StyleChanged += LookAndFeel_StyleChanged;
LookAndFeel_StyleChanged(null, null);
}
void LookAndFeel_StyleChanged(object sender, EventArgs e) {
XYDiagram xYDiagram = stockChart.Diagram as XYDiagram;
CustomAxisLabel customAxisLabel = xYDiagram.AxisY.CustomLabels[0];
customAxisLabel.BackColor = Skins.CommonSkins.GetSkin(stockChart.LookAndFeel).SvgPalettes[ObjectState.Normal].GetColor("Gray");
customAxisLabel.TextColor = Skins.CommonSkins.GetSkin(stockChart.LookAndFeel).SvgPalettes[ObjectState.Normal].GetColor("White");
}
void InitializeAdvancedIndicators() {
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new LinearRegressionItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new SimpleMovingAverageItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new ExponentialMovingAverageItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new TripleExponentialMovingAverageItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new TriangularMovingAverageItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new WeightedMovingAverageItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new MedianPriceItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new TypicalPriceItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new WeightedCloseItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new AverageTrueRangeItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new CommodityChannelIndexItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new DetrendedPriceOscillatorItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new MassIndexItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new MovingAverageConvergenceDivergenceItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new RateOfChangeItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new RelativeStrengthIndexItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new StandardDeviationItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new ChaikinsVolatilityItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items.Add(new WilliamsRItem());
repositoryItemCheckedComboBoxEditAdvancedIndicators.CustomDisplayText += Empty_CustomDisplayText;
}
void StockChartUC_Load(object sender, EventArgs e) {
if(StockMarketView.defaultViewModel == null)
return;
stockBarCheckItem.ImageOptions.SvgImage = SvgResources.GetSvgImage("Stock");
candleStickBarCheckItem.ImageOptions.SvgImage = SvgResources.GetSvgImage("Candles");
volumesBarCheckItem.ImageOptions.SvgImage = SvgResources.GetSvgImage("Bars");
barCheckItem3.ImageOptions.SvgImage = SvgResources.GetSvgImage("6m");
barCheckItem4.ImageOptions.SvgImage = SvgResources.GetSvgImage("1y");
barCheckItem5.ImageOptions.SvgImage = SvgResources.GetSvgImage("1-5y");
barCheckItem6.ImageOptions.SvgImage = SvgResources.GetSvgImage("2y");
barCheckItem7.ImageOptions.SvgImage = SvgResources.GetSvgImage("4y");
barCheckItemRemoveIndicator.ImageOptions.SvgImage = SvgResources.GetSvgImage("Remove");
barCheckItemTrendLine.ImageOptions.SvgImage = SvgResources.GetSvgImage("TrendLine");
barCheckItemFibonacciArcs.ImageOptions.SvgImage = SvgResources.GetSvgImage("FibonacciArcs");
barCheckItemFibonacciFans.ImageOptions.SvgImage = SvgResources.GetSvgImage("FibonacciFans");
barCheckItemFibonacciRetracement.ImageOptions.SvgImage = SvgResources.GetSvgImage("FibonacciRetracement");
//StockMarketView.defaultViewModel.model.InitServer();
OnPeriodChanged(barCheckItem7, null);
for(int i = 0; i < 6; i++)
repositoryItemCheckedComboBoxEditAdvancedIndicators.Items[i].CheckState = CheckState.Checked;
barEditItemAdvancedIndicators.EditValue = "Default";
}
void OnShowVolumeChartChanged(object sender, ItemClickEventArgs e) {
Diagram.Panes[0].Visibility = volumesBarCheckItem.Checked ? ChartElementVisibility.Visible : ChartElementVisibility.Hidden;
}
void OnPeriodChanged(object sender, ItemClickEventArgs e) {
BarCheckItem barCheckItem = sender as BarCheckItem;
if(barCheckItem != null && barCheckItem.Checked != false) {
daysCount = (int)barCheckItem.Tag;
repositoryItemComboBoxPeriod.Items.Clear();
foreach(PeriodItem periodItem in periods) {
int numberOfCandles = daysCount / periodItem.Ticks;
if(numberOfCandles >= MinCandleCount)
repositoryItemComboBoxPeriod.Items.Add(periodItem);
}
comboBoxBarEditItem.EditValue = repositoryItemComboBoxPeriod.Items[0];
OnTicksChanged(comboBoxBarEditItem, null);
}
}
void OnTicksChanged(object sender, EventArgs e) {
if(!ViewModel.RealTimeDataViewModel.IsReady) return;
BarEditItem barEditItem = sender as BarEditItem;
if(barEditItem != null && barEditItem.Name == "comboBoxBarEditItem") {
var vm = StockMarketView.defaultViewModel;
if(vm != null) {
int numberOfTicks = ((PeriodItem)barEditItem.EditValue).Ticks;
int newCandlesCount = daysCount / numberOfTicks;
if(vm.Ticks != numberOfTicks || vm.CandlesCount != newCandlesCount) {
vm.SetTicks(numberOfTicks);
vm.CandlesCount = newCandlesCount;
vm.OnCandlesCountChanged();
}
}
}
UpdateSeriesView();
}
void UpdateSeriesView() {
if(comboBoxBarEditItem.EditValue != null) {
switch(comboBoxBarEditItem.EditValue.ToString()) {
case "1 week":
Diagram.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Week;
PriceSeriesView.LevelLineLength = 0.3;
VolumeSeriesView.BarWidth = 0.8D;
break;
case "2 week":
Diagram.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Week;
PriceSeriesView.LevelLineLength = 0.6;
VolumeSeriesView.BarWidth = 1.6D;
break;
case "1 month":
Diagram.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Month;
PriceSeriesView.LevelLineLength = 0.3;
VolumeSeriesView.BarWidth = 0.8D;
break;
}
}
}
void ChangeViewToCandleStick(object sender, ItemClickEventArgs e) {
stockChart.Series[PriceSeriesName].ChangeView(ViewType.CandleStick);
}
void ChangeViewToStock(object sender, ItemClickEventArgs e) {
stockChart.Series[PriceSeriesName].ChangeView(ViewType.Stock);
}
void stockChart_MouseMove(object sender, MouseEventArgs e) {
if(isDrawing) {
DiagramCoordinates coords = Diagram.PointToDiagram(e.Location);
draggingIndicator.Point2.Argument = coords.DateTimeArgument;
trendlineBorder.AxisValue = coords.DateTimeArgument;
}
}
void stockChart_MouseUp(object sender, MouseEventArgs e) {
if(!isSelection) {
draggingIndicator = null;
Diagram.AxisX.ConstantLines.Remove(trendlineBorder);
trendlineBorder = null;
isDrawing = false;
stockChart.Capture = false;
}
}
void stockChart_MouseDown(object sender, MouseEventArgs e) {
if(!isSelection) {
draggingIndicator = CreateDraggingIndicator();
if(draggingIndicator == null)
return;
DiagramCoordinates coords = Diagram.PointToDiagram(e.Location);
draggingIndicator.Point1.Argument = coords.DateTimeArgument;
draggingIndicator.Point1.ValueLevel = ValueLevel.Close;
draggingIndicator.Point2.Argument = coords.DateTimeArgument;
draggingIndicator.Point2.ValueLevel = ValueLevel.Close;
PriceSeriesView.Indicators.Add(draggingIndicator);
trendlineBorder = new ConstantLine();
trendlineBorder.AxisValue = coords.DateTimeArgument;
trendlineBorder.LineStyle.DashStyle = DashStyle.Dash;
trendlineBorder.LineStyle.Thickness = 1;
trendlineBorder.ShowInLegend = false;
Diagram.AxisX.ConstantLines.Add(trendlineBorder);
stockChart.Capture = true;
isDrawing = true;
stockChart.Capture = true;
}
}
void stockChart_ObjectHotTracked(object sender, HotTrackEventArgs e) {
if(!isSelection || !e.HitInfo.InIndicator)
e.Cancel = true;
else if(e.HitInfo.InIndicator) {
Indicator indicator = e.HitInfo.Indicator;
if(!(indicator is TrendLine) && !(indicator is FibonacciIndicator))
e.Cancel = true;
}
}
void stockChart_ObjectSelected(object sender, HotTrackEventArgs e) {
if(isSelection && e.HitInfo.InIndicator) {
Indicator indicator = e.HitInfo.Indicator;
if(indicator is TrendLine || indicator is FibonacciIndicator)
ChartHelper.RemoveIndicator(stockChart, PriceSeriesView, indicator);
}
e.Cancel = true;
}
void barEditItemMovingAverageIndicators_EditValueChanged(object sender, EventArgs e) {
foreach(CheckedListBoxItem item in repositoryItemCheckedComboBoxEditMovingAverages.Items) {
CheckedIndicatorItem movingAverage = (CheckedIndicatorItem)item.Value;
movingAverage.UpdateIndicator(stockChart, PriceSeriesView, item.CheckState == CheckState.Checked);
}
}
void barEditItemAdvancedIndicators_EditValueChanged(object sender, EventArgs e) {
foreach(CheckedListBoxItem item in repositoryItemCheckedComboBoxEditAdvancedIndicators.Items) {
CheckedIndicatorItem indicatorItem = (CheckedIndicatorItem)item.Value;
indicatorItem.UpdateIndicator(stockChart, PriceSeriesView, item.CheckState == CheckState.Checked);
}
}
void Empty_CustomDisplayText(object sender, CustomDisplayTextEventArgs e) {
if(string.IsNullOrEmpty(e.DisplayText))
e.DisplayText = "None";
}
void UpdateDrawingItemChecked(BarCheckItem item, BarCheckItem changedItem) {
if(item != changedItem)
item.Checked = false;
}
void UpdateDrawingItems(object sender, ItemClickEventArgs e) {
BarCheckItem item = (BarCheckItem)sender;
if(item.Checked) {
UpdateDrawingItemChecked(barCheckItemTrendLine, item);
UpdateDrawingItemChecked(barCheckItemFibonacciArcs, item);
UpdateDrawingItemChecked(barCheckItemFibonacciFans, item);
UpdateDrawingItemChecked(barCheckItemFibonacciRetracement, item);
UpdateDrawingItemChecked(barCheckItemRemoveIndicator, item);
}
stockChart.CrosshairEnabled = barCheckItemTrendLine.Checked || barCheckItemFibonacciArcs.Checked || barCheckItemFibonacciFans.Checked ||
barCheckItemFibonacciRetracement.Checked || barCheckItemRemoveIndicator.Checked ? DefaultBoolean.False : DefaultBoolean.True;
}
void barCheckItemRemoveIndicator_CheckedChanged(object sender, ItemClickEventArgs e) {
isSelection = ((BarCheckItem)sender).Checked;
UpdateDrawingItems(sender, e);
}
void stockChart_BoundDataChanged(object sender, EventArgs e) {
if(PriceSeries.Points.Count > 0) {
Diagram.AxisY.CustomLabels[0].AxisValue = PriceSeries.Points[PriceSeries.Points.Count - 1].Values[3];
Diagram.AxisY.CustomLabels[0].Name = String.Format("${0:F1}", Diagram.AxisY.CustomLabels[0].AxisValue);
}
}
FinancialIndicator CreateDraggingIndicator() {
if(barCheckItemTrendLine.Checked)
return new TrendLine("TrendLine");
if(barCheckItemFibonacciArcs.Checked)
return new FibonacciIndicator(FibonacciIndicatorKind.FibonacciArcs, "FibonacciArcs");
if(barCheckItemFibonacciFans.Checked)
return new FibonacciIndicator(FibonacciIndicatorKind.FibonacciFans, "FibonacciFans");
if(barCheckItemFibonacciRetracement.Checked)
return new FibonacciIndicator(FibonacciIndicatorKind.FibonacciRetracement, "FibonacciRetracement");
return null;
}
}
public class PeriodItem {
public PeriodItem(string caption, int ticks) {
Caption = caption;
Ticks = ticks;
}
public override string ToString() {
return Caption;
}
public string Caption {
get;
private set;
}
public int Ticks {
get;
private set;
}
}
//
public class SvgResources {
const string prefix = "DevExpress.StockMarketTrader.ImagesSvg.";
const string ext = ".svg";
readonly static Dictionary<string, SvgImage> svgImages = new Dictionary<string, SvgImage>(20);
public static SvgImage GetSvgImage(string imageName) {
SvgImage svgImage;
if(!svgImages.TryGetValue(imageName, out svgImage)) {
svgImage = ResourceImageHelper.CreateSvgImageFromResources(prefix + imageName + ext, typeof(SvgResources).Assembly);
svgImages.Add(imageName, svgImage);
}
return svgImage;
}
}
}

View File

@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="barManager1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="barAndDockingController1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>142, 17</value>
</metadata>
</root>