Index: /branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/ChangeColumnGroup/CreateTimeSeriesColumnsCommand.cs
===================================================================
--- /branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/ChangeColumnGroup/CreateTimeSeriesColumnsCommand.cs	(revision 6136)
+++ /branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/ChangeColumnGroup/CreateTimeSeriesColumnsCommand.cs	(revision 6137)
@@ -33,17 +33,11 @@
 namespace HeuristicLab.DataImporter.Command {
   [StorableClass]
-  [ViewableCommandInfo("Create time series columns", 1, ColumnGroupState.ColumnSelected, "Column Commands",
-    Position = 16, SelectedColumns = 1)]
-  public class CreateTimeSeriesColumnsCommand : ColumnCommandBase {
+  [ViewableCommandInfo("Create time series columns", 1, ColumnGroupState.DoubleColumnSelected, "Column Commands",
+    Position = 16, SelectedColumns = 4)]
+  public class CreateTimeSeriesColumnsCommand : ColumnGroupCommandWithAffectedColumnsBase {
     private int addedColumnsCount;
-    private const double SETVALUE = 1.0;
-    private const double NOTSETVALUE = 0.0;
-
-    private CreateTimeSeriesColumnsCommand()
-      : base(null, string.Empty, -1) {
-    }
-
-    public CreateTimeSeriesColumnsCommand(DataSet dataSet, string columnGroupName, int columnIndex)
-      : base(dataSet, columnGroupName, columnIndex) {
+
+    public CreateTimeSeriesColumnsCommand(DataSet dataSet, string columnGroupName, int[] affectedColumns)
+      : base(dataSet, columnGroupName, affectedColumns) {
     }
 
@@ -54,107 +48,177 @@
     public override void Execute() {
       base.Execute();
-
-      //if (Column.NullValuesCount != 0)
-      //  throw new CommandExecutionException("Categorial column must not contain null values.", this);
-
-      //int columnIndex = this.ColumnGroup.IndexOfColumn(Column);
-      //Dictionary<string, DoubleColumn> addedColumns = new Dictionary<string, DoubleColumn>();
-      //foreach (string value in Column.ValuesEnumerable.Cast<IComparable>().Distinct().OrderBy(c => c).Select(o => o.ToString())) {
-      //  DoubleColumn doubleColumn = new DoubleColumn(Column.Name + " " + value.ToString());
-      //  addedColumns[value] = doubleColumn;
-      //  ColumnGroup.InsertColumn(columnIndex + addedColumnsCount + 1, doubleColumn);
-      //  addedColumnsCount++;
-      //}
-
-      //for (int row = 0; row < ColumnGroup.RowCount; row++) {
-      //  string value = Column.GetValue(row).ToString();
-      //  foreach (KeyValuePair<string, DoubleColumn> pair in addedColumns) {
-      //    if (pair.Key == value)
-      //      pair.Value.AddValue(SETVALUE);
-      //    else
-      //      pair.Value.AddValue(NOTSETVALUE);
-      //  }
-      //}
-
-      // Set Formula Name
+      if (AffectedColumns.Length != 4) throw new CommandExecutionException("The selected columns must include high, low, open, and close price.", this);
+      string[] seriesNames = { "high", "low", "open", "close" };
       Chart chart1 = new Chart();
-      string formulaName = "DetrendedPriceOscillator";
-
-      FinancialFormula formula = (FinancialFormula)Enum.Parse(typeof(FinancialFormula), formulaName, true);
-      
-      // Formulas with one input value
-      if (formulaName == "DetrendedPriceOscillator" || formulaName == "MovingAverageConvergenceDivergence" || formulaName == "Performance" || formulaName == "RateOfChange"
-      || formulaName == "TripleExponentialMovingAverage") {
+      // Y = high
+      // Y2 = low
+      // Y3 = open
+      // Y4 = close
+      List<DoubleColumn> columns = new List<DoubleColumn>();
+      for (int i = 0; i < 4; i++) {
+        int columnIndex = AffectedColumns[i];
+        DoubleColumn doubleColumn = ColumnGroup.GetColumn(columnIndex) as DoubleColumn;
+        if (doubleColumn == null) throw new CommandExecutionException("The selection column does not contain double columns.", this);
+        columns.Add(doubleColumn);
+      }
+      Series series = new Series();
+      series.ChartArea = "Default";
+      series.ChartType = SeriesChartType.Stock;
+      series.Name = "Input";
+      series.YValuesPerPoint = 4;
+      for (int i = 0; i < columns[0].TotalValuesCount; i++) {
+        DataPoint point = new DataPoint();
+        List<double> values = new List<double>();
+        for (int j = 0; j < 4; j++) {
+          double? v = (double?)columns[j].GetValue(i);
+          if (!v.HasValue) throw new CommandExecutionException("Columns must not contain missing values.", this);
+          values.Add(v.Value);
+        }
+        point.YValues = values.ToArray();
+        series.Points.AddXY(i, values[0]);
+        series.Points[i].YValues[1] = values[1];
+        series.Points[i].YValues[2] = values[2];
+        series.Points[i].YValues[3] = values[3];
+      }
+      chart1.Series.Add(series);
+
+
+      DoubleColumn firstAffectedColumn = (DoubleColumn)ColumnGroup.GetColumn(AffectedColumns[0]);
+      int lastAffectedColumn = AffectedColumns[3];
+
+      // formulas using only the close price
+      FinancialFormula[] formulae = new FinancialFormula[] { 
+        FinancialFormula.DetrendedPriceOscillator, 
+        FinancialFormula.MovingAverageConvergenceDivergence,
+        FinancialFormula.Performance, 
+        FinancialFormula.RateOfChange, 
+        FinancialFormula.RelativeStrengthIndex, 
+        FinancialFormula.StandardDeviation };
+      int currentColumnIndex = lastAffectedColumn + 1;
+      addedColumnsCount = 0;
+      foreach (var formula in formulae) {
         chart1.DataManipulator.FinancialFormula(formula, "10", "Input:Y4", "Indicators");
-      }
-
-      // Relative Strength Index
-      else if (formulaName == "RelativeStrengthIndex") {
-
-        chart1.DataManipulator.FinancialFormula(formula, "10", "Input:Y4", "Indicators");
-
-        // Set minimum and maximum for Y axis
-        chart1.ChartAreas["Indicator"].AxisY.Minimum = 0;
-        chart1.ChartAreas["Indicator"].AxisY.Maximum = 100;
-
-        // Create strip lines used with Relative strength index.
-        StripLine stripLine = new StripLine();
-        chart1.ChartAreas["Indicator"].AxisY.StripLines.Add(stripLine);
-        stripLine.Interval = 70;
-        stripLine.StripWidth = 30;
-        stripLine.BackColor = Color.FromArgb(128, 255, 255, 0);
-        stripLine.BorderColor = Color.Teal;
-
+
+        DoubleColumn newColumn = (DoubleColumn)firstAffectedColumn.CreateCopyOfColumnWithoutValues();
+        newColumn.Name = formula + "(" + firstAffectedColumn.Name + ")";
+        for (int i = 0; i < chart1.Series["Indicators"].Points.First().XValue; i++) {
+          newColumn.AddValue(null);
+        }
+        foreach (var value in chart1.Series["Indicators"].Points) {
+          newColumn.AddValue(value.YValues[0]);
+        }
+        this.ColumnGroup.InsertColumn(currentColumnIndex, newColumn);
+        currentColumnIndex++;
+        addedColumnsCount++;
+      }
+
+      // Formulas with two input value
+      formulae = new FinancialFormula[] {
+        FinancialFormula.MassIndex,
+        FinancialFormula.VolatilityChaikins
+      };
+      foreach (var formula in formulae) {
+        chart1.DataManipulator.FinancialFormula(formula, "20", "Input:Y,Input:Y2", "Indicators");
+
+        DoubleColumn newColumn = (DoubleColumn)firstAffectedColumn.CreateCopyOfColumnWithoutValues();
+        newColumn.Name = formula + "(" + firstAffectedColumn.Name + ")";
+        for (int i = 0; i < chart1.Series["Indicators"].Points.First().XValue; i++) {
+          newColumn.AddValue(null);
+        }
+        foreach (var value in chart1.Series["Indicators"].Points) {
+          newColumn.AddValue(value.YValues[0]);
+        }
+        this.ColumnGroup.InsertColumn(currentColumnIndex, newColumn);
+        currentColumnIndex++;
+        addedColumnsCount++;
       }
 
       // Williams %R
-      else if (formulaName == "WilliamsR") {
-
+      {
+        chart1.DataManipulator.FinancialFormula(FinancialFormula.WilliamsR, "Input:Y,Input:Y2,Input:Y4", "Indicators");
+        DoubleColumn newColumn = (DoubleColumn)firstAffectedColumn.CreateCopyOfColumnWithoutValues();
+        newColumn.Name = "WilliamsR(" + firstAffectedColumn.Name + ")";
+        for (int i = 0; i < chart1.Series["Indicators"].Points.First().XValue; i++) {
+          newColumn.AddValue(null);
+        }
+        foreach (var value in chart1.Series["Indicators"].Points) {
+          newColumn.AddValue(value.YValues[0]);
+        }
+        this.ColumnGroup.InsertColumn(currentColumnIndex, newColumn);
+        currentColumnIndex++;
+        addedColumnsCount++;
+      }
+
+      // StochasticIndicator
+      {
+        chart1.DataManipulator.FinancialFormula(FinancialFormula.StochasticIndicator, "15", "Input:Y,Input:Y2,Input:Y4", "Indicators,SMA");
+        DoubleColumn newColumn = (DoubleColumn)firstAffectedColumn.CreateCopyOfColumnWithoutValues();
+        newColumn.Name = "StochasticIndicator(" + firstAffectedColumn.Name + ")";
+        for (int i = 0; i < chart1.Series["Indicators"].Points.First().XValue; i++) {
+          newColumn.AddValue(null);
+        }
+        foreach (var value in chart1.Series["Indicators"].Points) {
+          newColumn.AddValue(value.YValues[0]);
+        }
+        this.ColumnGroup.InsertColumn(currentColumnIndex, newColumn);
+        currentColumnIndex++;
+        addedColumnsCount++;
+
+        DoubleColumn newColumnSma = (DoubleColumn)firstAffectedColumn.CreateCopyOfColumnWithoutValues();
+        newColumnSma.Name = "StochasticIndicator-SMA(" + firstAffectedColumn.Name + ")";
+        for (int i = 0; i < chart1.Series["SMA"].Points.First().XValue; i++) {
+          newColumnSma.AddValue(null);
+        }
+        foreach (var value in chart1.Series["SMA"].Points) {
+          newColumnSma.AddValue(value.YValues[0]);
+        }
+        this.ColumnGroup.InsertColumn(currentColumnIndex, newColumnSma);
+        currentColumnIndex++;
+        addedColumnsCount++;
+      }
+
+
+      // All other formulas.
+      formulae = new FinancialFormula[] {
+        FinancialFormula.AverageTrueRange,
+        FinancialFormula.CommodityChannelIndex,
+      };
+      foreach (var formula in formulae) {
         chart1.DataManipulator.FinancialFormula(formula, "Input:Y,Input:Y2,Input:Y4", "Indicators");
-
-        // Set minimum and maximum for Y axis
-        chart1.ChartAreas["Indicator"].AxisY.Minimum = -100;
-        chart1.ChartAreas["Indicator"].AxisY.Maximum = 0;
-
-        // Create strip lines used with Williams %R index.
-        StripLine stripLine = new StripLine();
-        chart1.ChartAreas["Indicator"].AxisY.StripLines.Add(stripLine);
-        stripLine.Interval = 80;
-        stripLine.StripWidth = 20;
-        stripLine.BackColor = Color.FromArgb(128, 255, 255, 0);
-        stripLine.BorderColor = Color.Teal;
-
-      }
-
-      // Formulas with two input value
-      else if (formulaName == "MassIndex" || formulaName == "VolatilityChaikins" || formulaName == "Performance") {
-        chart1.DataManipulator.FinancialFormula(formula, "20", "Input:Y,Input:Y2", "Indicators");
-      }
-
-      // Standard deviation
-      else if (formulaName == "StandardDeviation") {
+        DoubleColumn newColumn = (DoubleColumn)firstAffectedColumn.CreateCopyOfColumnWithoutValues();
+        newColumn.Name = formula + "(" + firstAffectedColumn.Name + ")";
+        for (int i = 0; i < chart1.Series["Indicators"].Points.First().XValue; i++) {
+          newColumn.AddValue(null);
+        }
+        foreach (var value in chart1.Series["Indicators"].Points) {
+          newColumn.AddValue(value.YValues[0]);
+        }
+        this.ColumnGroup.InsertColumn(currentColumnIndex, newColumn);
+        currentColumnIndex++;
+        addedColumnsCount++;
+      }
+
+      // moving averages.
+      formulae = new FinancialFormula[] {
+        FinancialFormula.ExponentialMovingAverage,
+        FinancialFormula.MovingAverage,
+        FinancialFormula.TriangularMovingAverage,
+        FinancialFormula.TripleExponentialMovingAverage, 
+        FinancialFormula.WeightedMovingAverage,
+      };
+      foreach (var formula in formulae) {
         chart1.DataManipulator.FinancialFormula(formula, "15", "Input:Y4", "Indicators");
-      }
-
-      // StochasticIndicator
-      else if (formulaName == "StochasticIndicator") {
-
-        chart1.DataManipulator.FinancialFormula(formula, "15", "Input:Y,Input:Y2,Input:Y4", "Indicators,SMA");
-
-        // Set attributes for Simple moving average series.
-        chart1.Series["SMA"].ChartType = SeriesChartType.Line;
-        chart1.Series["SMA"].Color = Color.Yellow;
-        chart1.Series["SMA"].ChartArea = "Indicator";
-        chart1.Series["SMA"].BorderWidth = 2;
-
-      }
-        // All other formulas.
-      else {
-        chart1.DataManipulator.FinancialFormula(formula, "Input:Y,Input:Y2,Input:Y4", "Indicators");
-      }
-
-      // Set minimum for X axis
-      chart1.ChartAreas["Indicator"].AxisX.Minimum = DateTime.Parse("1/1/2002").ToOADate();
-   
+        DoubleColumn newColumn = (DoubleColumn)firstAffectedColumn.CreateCopyOfColumnWithoutValues();
+        newColumn.Name = formula + "(" + firstAffectedColumn.Name + ")";
+        for (int i = 0; i < chart1.Series["Indicators"].Points.First().XValue; i++) {
+          newColumn.AddValue(null);
+        }
+        foreach (var value in chart1.Series["Indicators"].Points) {
+          newColumn.AddValue(value.YValues[0]);
+        }
+        this.ColumnGroup.InsertColumn(currentColumnIndex, newColumn);
+        currentColumnIndex++;
+        addedColumnsCount++;
+      }
 
       ColumnGroup.FireChanged();
@@ -163,7 +227,7 @@
     public override void UndoExecute() {
       base.UndoExecute();
-      int columnIndex = this.ColumnGroup.IndexOfColumn(Column);
+      int lastAffectedColumnIndex = AffectedColumns[3];
       for (int i = 0; i < addedColumnsCount; i++)
-        this.ColumnGroup.RemoveColumn(columnIndex + 1);
+        this.ColumnGroup.RemoveColumn(lastAffectedColumnIndex + 1);
       addedColumnsCount = 0;
       ColumnGroup.FireChanged();
Index: /branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.DataProcessor/DataProcessorView.Designer.cs
===================================================================
--- /branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.DataProcessor/DataProcessorView.Designer.cs	(revision 6136)
+++ /branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.DataProcessor/DataProcessorView.Designer.cs	(revision 6137)
@@ -46,5 +46,4 @@
     /// </summary>
     private void InitializeComponent() {
-      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DataProcessorView));
       this.menuStrip1 = new System.Windows.Forms.MenuStrip();
       this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -315,5 +314,5 @@
       // 
       this.newToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
-      this.newToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("newToolStripButton.Image")));
+      this.newToolStripButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument;// ((System.Drawing.Image)(resources.GetObject("newToolStripButton.Image")));
       this.newToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
       this.newToolStripButton.Name = "newToolStripButton";
@@ -325,5 +324,5 @@
       // 
       this.openToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
-      this.openToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("openToolStripButton.Image")));
+      this.openToolStripButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open; // ((System.Drawing.Image)(resources.GetObject("openToolStripButton.Image")));
       this.openToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
       this.openToolStripButton.Name = "openToolStripButton";
@@ -335,5 +334,5 @@
       // 
       this.saveToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
-      this.saveToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripButton.Image")));
+      this.saveToolStripButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Save; // ((System.Drawing.Image)(resources.GetObject("saveToolStripButton.Image")));
       this.saveToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
       this.saveToolStripButton.Name = "saveToolStripButton";
