Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/AverageTrade.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/AverageTrade.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/AverageTrade.cs	(revision 9139)
@@ -0,0 +1,37 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Core;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Common;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    [StorableClass]
+    [Item("Average", "Symbol that represents the average (arithmetic mean) function.")]
+    public class AverageTrade : Symbol
+    {
+        private const int minimumArity = 1;
+        private const int maximumArity = 1;
+
+        public override int MinimumArity
+        {
+            get { return minimumArity; }
+        }
+        public override int MaximumArity
+        {
+            get { return maximumArity; }
+        }
+
+        [StorableConstructor]
+        private AverageTrade(bool deserializing) : base(deserializing) { }
+        private AverageTrade(AverageTrade original, Cloner cloner) : base(original, cloner) { }
+        public override IDeepCloneable Clone(Cloner cloner)
+        {
+            return new AverageTrade(this, cloner);
+        }
+        public AverageTrade() : base("AverageTrade", "Symbol that represents the average (arithmetic mean) function.") { }
+    }
+}
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/BoolConstant.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/BoolConstant.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/BoolConstant.cs	(revision 9139)
@@ -0,0 +1,50 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    [StorableClass]
+    [Item("BoolConstant", "Represents a BoolConstant value.")]
+    public sealed class BoolConstant : Symbol
+    {
+        private const int minimumArity = 0;
+        private const int maximumArity = 0;
+
+        public override int MinimumArity
+        {
+            get { return minimumArity; }
+        }
+        public override int MaximumArity
+        {
+            get { return maximumArity; }
+        }
+
+
+        [StorableConstructor]
+        private BoolConstant(bool deserializing) : base(deserializing) { }
+        private BoolConstant(BoolConstant original, Cloner cloner)
+            : base(original, cloner)
+        {
+        }
+        public BoolConstant()
+            : base("BoolConstant", "Represents a BoolConstant value.")
+        {
+        }
+
+        public override ISymbolicExpressionTreeNode CreateTreeNode()
+        {
+            return new BoolConstantTreeNode(this);
+        }
+
+        public override IDeepCloneable Clone(Cloner cloner)
+        {
+            return new BoolConstant(this, cloner);
+        }
+    }
+}
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/BoolConstantTreeNode.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/BoolConstantTreeNode.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/BoolConstantTreeNode.cs	(revision 9139)
@@ -0,0 +1,59 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Random;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    [StorableClass]
+    public sealed class BoolConstantTreeNode : SymbolicExpressionTreeTerminalNode
+    {
+
+      public new BoolConstant Symbol {
+      get { return (BoolConstant)base.Symbol; }
+    }
+
+    private double BoolConstantValue;
+    [Storable]
+    public double Value {
+      get { return BoolConstantValue; }
+      set { BoolConstantValue = value; }
+    }
+
+    [StorableConstructor]
+    private BoolConstantTreeNode(bool deserializing) : base(deserializing) { }
+
+    private BoolConstantTreeNode(BoolConstantTreeNode original, Cloner cloner)
+      : base(original, cloner) {
+      BoolConstantValue = original.BoolConstantValue;
+    }
+
+    private BoolConstantTreeNode() : base() { }
+    public BoolConstantTreeNode(BoolConstant BoolConstantSymbol) : base(BoolConstantSymbol) { }
+
+    public override bool HasLocalParameters {
+      get {
+        return true;
+      }
+    }
+    public override void ResetLocalParameters(IRandom random) {
+      base.ResetLocalParameters(random);
+      if (random.Next(1) == 0) Value = -1;
+      else Value = 1;
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new BoolConstantTreeNode(this, cloner);
+    }
+
+    public override string ToString() {
+      return BoolConstantValue.ToString("E5");
+    }
+  }
+}
+
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/ConstantInt.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/ConstantInt.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/ConstantInt.cs	(revision 9139)
@@ -0,0 +1,50 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    [StorableClass]
+    [Item("ConstantInt", "Represents a ConstantInt value.")]
+    public sealed class ConstantInt : Symbol
+    {
+        private const int minimumArity = 0;
+        private const int maximumArity = 0;
+
+        public override int MinimumArity
+        {
+            get { return minimumArity; }
+        }
+        public override int MaximumArity
+        {
+            get { return maximumArity; }
+        }
+
+
+        [StorableConstructor]
+        private ConstantInt(bool deserializing) : base(deserializing) { }
+        private ConstantInt(ConstantInt original, Cloner cloner)
+            : base(original, cloner)
+        {
+        }
+        public ConstantInt()
+            : base("ConstantInt", "Represents a ConstantInt value.")
+        {
+        }
+
+        public override ISymbolicExpressionTreeNode CreateTreeNode()
+        {
+            return new ConstantIntTreeNode(this);
+        }
+
+        public override IDeepCloneable Clone(Cloner cloner)
+        {
+            return new ConstantInt(this, cloner);
+        }
+    }
+}
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/ConstantIntTreeNode.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/ConstantIntTreeNode.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/ConstantIntTreeNode.cs	(revision 9139)
@@ -0,0 +1,66 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Random;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    [StorableClass]
+    public sealed class ConstantIntTreeNode : SymbolicExpressionTreeTerminalNode
+    {
+
+        public new ConstantInt Symbol
+        {
+            get { return (ConstantInt)base.Symbol; }
+        }
+
+        private double ConstantIntValue;
+        [Storable]
+        public double Value
+        {
+            get { return ConstantIntValue; }
+            set { ConstantIntValue = value; }
+        }
+
+        [StorableConstructor]
+        private ConstantIntTreeNode(bool deserializing) : base(deserializing) { }
+
+        private ConstantIntTreeNode(ConstantIntTreeNode original, Cloner cloner)
+            : base(original, cloner)
+        {
+            ConstantIntValue = original.ConstantIntValue;
+        }
+
+        private ConstantIntTreeNode() : base() { }
+        public ConstantIntTreeNode(ConstantInt ConstantIntSymbol) : base(ConstantIntSymbol) { }
+
+        public override bool HasLocalParameters
+        {
+            get
+            {
+                return true;
+            }
+        }
+        public override void ResetLocalParameters(IRandom random)
+        {
+            base.ResetLocalParameters(random);
+            
+            Value = random.Next(99)+1;
+        }
+
+        public override IDeepCloneable Clone(Cloner cloner)
+        {
+            return new ConstantIntTreeNode(this, cloner);
+        }
+
+        public override string ToString()
+        {
+            return ConstantIntValue.ToString("E5");
+        }
+    }
+}
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/EMA.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/EMA.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/EMA.cs	(revision 9139)
@@ -0,0 +1,51 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Core;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Common;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+
+    [StorableClass]
+    [Item("EMA", "Represents a EMA value.")]
+    public class EMA : Symbol
+    {
+        private const int minimumArity = 1;
+        private const int maximumArity = 1;
+
+        public override int MinimumArity
+        {
+            get { return minimumArity; }
+        }
+        public override int MaximumArity
+        {
+            get { return maximumArity; }
+        }
+
+        [StorableConstructor]
+        protected EMA(bool deserializing)
+            : base(deserializing)
+        {
+            
+        }
+        protected EMA(EMA original, Cloner cloner)
+            : base(original, cloner)
+        {
+
+        }
+        public EMA() : this("EMA", "Represents a EMA value.") { }
+        public EMA(string name, string description)
+            : base(name, description)
+        {
+        }
+
+        public override IDeepCloneable Clone(Cloner cloner)
+        {
+            return new EMA(this, cloner);
+        }
+    }
+}
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/EvaluatorTradeRules.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/EvaluatorTradeRules.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/EvaluatorTradeRules.cs	(revision 9139)
@@ -0,0 +1,145 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
+using HeuristicLab.Problems.DataAnalysis.Symbolic;
+using HeuristicLab.Problems.DataAnalysis;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    [Item("Trade Rules Evaluator", "Calculates the profit")]
+    [StorableClass]
+    public class EvaluatorTradeRules : SymbolicRegressionSingleObjectiveEvaluator
+    {
+
+        public override bool Maximization { get { return true; } }
+
+        [StorableConstructor]
+        protected EvaluatorTradeRules(bool deserializing) : base(deserializing) { }
+        protected EvaluatorTradeRules(EvaluatorTradeRules original, Cloner cloner)
+            : base(original, cloner)
+        {
+        }
+        public override IDeepCloneable Clone(Cloner cloner)
+        {
+            return new EvaluatorTradeRules(this, cloner);
+        }
+
+        public EvaluatorTradeRules() : base() { }
+
+        public override IOperation Apply()
+        {
+            var solution = SymbolicExpressionTreeParameter.ActualValue;
+            IEnumerable<int> rows = GenerateRowsToEvaluate();
+
+            double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows);
+            QualityParameter.ActualValue = new DoubleValue(quality);
+
+            return base.Apply();
+        }
+
+        public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows)
+        {
+            IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
+            const double commission = 0.25;
+
+            bool intoMarket = false;//Equivalent to be into the market
+            int totalTradeDays = 0;
+            int numberTrades = 0;
+            int tradeDays = 0;
+            double dayBefore = 0.0;
+            double yesterday = 0.0;
+            double buyPrice = 0.0;
+            double sellPrice = 0.0;
+            string stringPrice = "";
+            int nShares = 0;
+            double cash = 10000.00;
+            double expend = 0.0;
+            double equity = 0.0;
+            double profit1 = 0.0;
+            double charged = 0.0;
+
+            //SECOND EVALUATOR
+            IEnumerator<int> initialRow = rows.GetEnumerator();
+            initialRow.MoveNext();
+            int count = initialRow.Current + 2;
+            IEnumerator<double> enumerator = estimatedValues.GetEnumerator();
+            enumerator.MoveNext();
+            dayBefore = enumerator.Current;
+            enumerator.MoveNext();
+            yesterday = enumerator.Current;
+            while (enumerator.MoveNext())
+            {
+                if (!intoMarket)
+                {
+                    if (dayBefore == -1 && yesterday == 1)
+                    {
+                        intoMarket = true;
+                        stringPrice = problemData.Dataset.GetValue(count, 0); //Extracting Open values
+                        buyPrice = Convert.ToDouble(stringPrice);
+                        totalTradeDays++; numberTrades++; tradeDays++; //Increasing trading variables
+                        nShares = (int)Math.Floor(cash / (buyPrice * (1.0 + commission / 100)));
+                        expend = buyPrice * nShares * (1 + commission / 100);
+                        cash = cash - expend;
+                        equity = cash + nShares * buyPrice * (1 + commission / 100);
+                    }
+                }
+                else if (dayBefore == 1 && yesterday == -1)
+                {
+                    intoMarket = false;
+                    stringPrice = problemData.Dataset.GetValue(count, 0); //Extracting Open values
+                    sellPrice = Convert.ToDouble(stringPrice);
+                    profit1 += sellPrice - buyPrice;
+                    charged = sellPrice * nShares * (1 - commission / 100);
+                    cash = cash + charged;
+                    equity = cash;
+                    nShares = 0;
+                }
+                else
+                {
+                    tradeDays++;
+                    totalTradeDays++;
+                    equity = cash + nShares * Convert.ToDouble(problemData.Dataset.GetValue(count, 0)) * (1 + commission / 100);
+                }
+
+                dayBefore = yesterday;
+                yesterday = enumerator.Current;
+                count++;
+            }
+
+            if (intoMarket)
+            {
+                intoMarket = false;
+                stringPrice = problemData.Dataset.GetValue(count, 0); //Extracting Open values
+                sellPrice = Convert.ToDouble(stringPrice);
+                profit1 += sellPrice - buyPrice;
+                charged = sellPrice * nShares * (1 - commission / 100);
+                cash = cash + charged;
+                equity = cash;
+                nShares = 0;
+            }
+
+            return cash;
+        }
+
+        public override double Evaluate(IExecutionContext context, ISymbolicExpressionTree tree, IRegressionProblemData problemData, IEnumerable<int> rows)
+        {
+            SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = context;
+            EstimationLimitsParameter.ExecutionContext = context;
+
+            double r2 = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows);
+
+            SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
+            EstimationLimitsParameter.ExecutionContext = null;
+
+            return r2;
+        }
+    }
+}
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/Grammar.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/Grammar.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/Grammar.cs	(revision 9139)
@@ -0,0 +1,161 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.TradeRules;
+using HeuristicLab.Problems.DataAnalysis.Symbolic;
+using System;
+using HeuristicLab.Core;
+namespace HeuristicLab.Problems.TradeRules {
+  [StorableClass]
+  [Item("Grammar", "Represents a grammar for functional expressions in which special syntactic constraints are enforced so that boolean and real-valued expressions are not mixed.")]
+    public class Grammar : SymbolicExpressionGrammar, ISymbolicDataAnalysisGrammar
+    {
+    private const string ArithmeticFunctionsName = "Arithmetic Functions";
+    private const string TerminalsName = "Terminals";
+    private const string ComparisonsName = "Comparisons";
+    private const string BooleanOperatorsName = "Boolean Operators";
+    private const string ConditionalSymbolsName = "ConditionalSymbols";
+    private const string BooleanConstant = "Boolean Constant";
+    private const string TradeMean = "Average Trade";
+    private const string MACDIndicator = "MACD Indicator";
+    private const string SerialTime = "Serial Operators";
+      
+    [StorableConstructor]
+    protected Grammar(bool deserializing) : base(deserializing) { }
+    protected Grammar(Grammar original, Cloner cloner) : base(original, cloner) { }
+    public Grammar()
+      : base(ItemAttribute.GetName(typeof(Grammar)), ItemAttribute.GetDescription(typeof(Grammar))) {
+      Initialize();
+    }
+    public override IDeepCloneable Clone(Cloner cloner)
+    {
+        return new Grammar(this, cloner);
+    }
+
+    private void Initialize()
+    {
+        #region symbol declaration
+        var add = new Addition();
+        var sub = new Subtraction();
+        var mul = new Multiplication();
+
+        var mean = new AverageTrade();
+        var expMovAverage = new EMA();
+        var macd = new MACD();
+        var RSI = new RSI();
+
+        var gt = new GreaterThan();
+        var lt = new LessThan();
+        var and = new And();
+        var or = new Or();
+        var not = new Not();
+
+        var constantint = new ConstantInt();
+        var boolean = new BoolConstant();
+
+        var max = new Max();
+        var min = new Min();
+        var lag = new Lag();
+        var variableSymbol = new HeuristicLab.Problems.DataAnalysis.Symbolic.Variable();
+        #endregion
+
+        #region group symbol declaration
+        var arithmeticSymbols = new GroupSymbol(ArithmeticFunctionsName, new List<ISymbol>() { add, sub, mul}); 
+        var terminalSymbols = new GroupSymbol(TerminalsName, new List<ISymbol> {constantint, variableSymbol });
+
+        var comparisonSymbols = new GroupSymbol(ComparisonsName, new List<ISymbol> { gt, lt });
+        var booleanOperationSymbols = new GroupSymbol(BooleanOperatorsName, new List<ISymbol> { and, or, not });
+        var booleanConstantsSymbols = new GroupSymbol(BooleanConstant, new List<ISymbol> { boolean });
+        var meanTradeSymbols = new GroupSymbol(TradeMean, new List<ISymbol> { mean});
+        var indicatorTradeSymbols = new GroupSymbol(MACDIndicator, new List<ISymbol> { macd,RSI, expMovAverage });
+        
+        var serialTime = new GroupSymbol(SerialTime, new List<ISymbol> {max,min, lag });
+
+        #endregion
+
+        AddSymbol(comparisonSymbols);
+        AddSymbol(booleanOperationSymbols);
+        AddSymbol(arithmeticSymbols);
+        AddSymbol(terminalSymbols);
+        AddSymbol(booleanConstantsSymbols);
+        AddSymbol(meanTradeSymbols);
+        AddSymbol(indicatorTradeSymbols);
+        AddSymbol(serialTime);
+        
+
+        #region subtree count configuration
+        SetSubtreeCount(arithmeticSymbols, 2, 2);
+        SetSubtreeCount(terminalSymbols, 0, 0);
+
+        SetSubtreeCount(booleanConstantsSymbols, 0, 0);
+        SetSubtreeCount(meanTradeSymbols, 1, 1);
+        SetSubtreeCount(macd, 3, 3);
+        SetSubtreeCount(RSI, 1, 1);
+        SetSubtreeCount(expMovAverage, 1, 1);
+        SetSubtreeCount(comparisonSymbols, 2, 2);
+        SetSubtreeCount(and, 2, 2);
+        SetSubtreeCount(or, 2, 2);
+        SetSubtreeCount(not, 1, 1);
+        SetSubtreeCount(serialTime, 1, 1);
+      #endregion
+
+      #region allowed child symbols configuration
+        //AddAllowedChildSymbol(StartSymbol, booleanOperationSymbols);
+        //AddAllowedChildSymbol(StartSymbol, comparisonSymbols);
+        AddAllowedChildSymbol(StartSymbol, expMovAverage);
+
+        AddAllowedChildSymbol(booleanOperationSymbols, comparisonSymbols);
+        AddAllowedChildSymbol(booleanOperationSymbols, booleanConstantsSymbols);
+        //AddAllowedChildSymbol(booleanOperationSymbols, indicatorTradeSymbols);
+
+        AddAllowedChildSymbol(comparisonSymbols, meanTradeSymbols);
+        AddAllowedChildSymbol(comparisonSymbols, arithmeticSymbols);
+        AddAllowedChildSymbol(comparisonSymbols, terminalSymbols);
+        AddAllowedChildSymbol(comparisonSymbols, serialTime);
+
+        AddAllowedChildSymbol(arithmeticSymbols, arithmeticSymbols);
+        AddAllowedChildSymbol(arithmeticSymbols, meanTradeSymbols);
+        AddAllowedChildSymbol(arithmeticSymbols, terminalSymbols);
+        AddAllowedChildSymbol(arithmeticSymbols, serialTime);
+
+        AddAllowedChildSymbol(serialTime, constantint);
+
+        AddAllowedChildSymbol(meanTradeSymbols, constantint);
+        AddAllowedChildSymbol(indicatorTradeSymbols, constantint);
+      #endregion
+    }
+
+   public void ConfigureAsDefaultRegressionGrammar() {
+
+      // Symbols.First(s => s is Constant).Enabled = false;
+   }
+
+   public void ConfigureAsDefaultClassificationGrammar()
+   {
+     //  Symbols.First(s => s is Constant).Enabled = false;
+   }
+  }
+}
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/HeuristicLab.Problems.TradeRules-1.0.csproj
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/HeuristicLab.Problems.TradeRules-1.0.csproj	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/HeuristicLab.Problems.TradeRules-1.0.csproj	(revision 9139)
@@ -0,0 +1,136 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{1DC59B4F-516F-40E3-B8CF-3900FA7D32BF}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>HeuristicLab.Problems.TradeRules</RootNamespace>
+    <AssemblyName>HeuristicLab.Problems.TradeRules-1.0</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\bin\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Collections-3.3">
+      <HintPath>..\bin\HeuristicLab.Collections-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Common-3.3">
+      <HintPath>..\bin\HeuristicLab.Common-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Core-3.3">
+      <HintPath>..\bin\HeuristicLab.Core-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Data-3.3">
+      <HintPath>..\bin\HeuristicLab.Data-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4">
+      <HintPath>..\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Operators-3.3">
+      <HintPath>..\bin\HeuristicLab.Operators-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Operators.Programmable-3.3">
+      <HintPath>..\bin\HeuristicLab.Operators.Programmable-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Optimization-3.3">
+      <HintPath>..\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Optimizer-3.3">
+      <HintPath>..\bin\HeuristicLab.Optimizer-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Parameters-3.3">
+      <HintPath>..\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Persistence-3.3">
+      <HintPath>..\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
+      <HintPath>..\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\bin\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Problems.Instances-3.3">
+      <HintPath>..\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Random-3.3">
+      <HintPath>..\bin\HeuristicLab.Random-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AverageTrade.cs" />
+    <Compile Include="BoolConstant.cs" />
+    <Compile Include="BoolConstantTreeNode.cs" />
+    <Compile Include="ConstantInt.cs" />
+    <Compile Include="ConstantIntTreeNode.cs" />
+    <Compile Include="EMA.cs" />
+    <Compile Include="EvaluatorTradeRules.cs" />
+    <Compile Include="Grammar.cs" />
+    <Compile Include="Interpreter.cs" />
+    <Compile Include="Lag.cs" />
+    <Compile Include="MACD.cs" />
+    <Compile Include="Max.cs" />
+    <Compile Include="Min.cs" />
+    <Compile Include="Plugin.cs" />
+    <Compile Include="Properties\HeuristicLab.Problems.TradeRules-1.0.cs" />
+    <Compile Include="RSI.cs" />
+    <Compile Include="TradeAnalysisProblem.cs" />
+    <Compile Include="TradeRulesAbstractProblem.cs" />
+    <Compile Include="TradeRulesProblem.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj">
+      <Project>{5AC82412-911B-4FA2-A013-EDC5E3F3FCC2}</Project>
+      <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj">
+      <Project>{3D28463F-EC96-4D82-AFEE-38BE91A0CA00}</Project>
+      <Name>HeuristicLab.Problems.DataAnalysis.Symbolic-3.4</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/Interpreter.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/Interpreter.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/Interpreter.cs	(revision 9139)
@@ -0,0 +1,583 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.DataAnalysis.Symbolic;
+using HeuristicLab.Problems.DataAnalysis;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    [StorableClass]
+    [Item("Interpreter", "Represents a grammar for Trading Problems")]
+    public sealed class Interpreter : ParameterizedNamedItem, ISymbolicDataAnalysisExpressionTreeInterpreter
+    {
+        private const string CheckExpressionsWithIntervalArithmeticParameterName = "CheckExpressionsWithIntervalArithmetic";
+        private const string EvaluatedSolutionsParameterName = "EvaluatedSolutions";
+        [ThreadStatic]
+        private static double [] EMAValue;
+        [ThreadStatic]
+        private static double inOut;
+        [ThreadStatic]
+        private static double meanUp;
+        [ThreadStatic]
+        private static double meanDown;
+        [ThreadStatic]
+        private static double lastRSI;
+        #region private classes
+        //This class manipulate the instructions of the stack
+        private class InterpreterState
+        {
+            private double[] argumentStack;
+            private int argumentStackPointer;
+            private Instruction[] code;
+            private int pc;
+            public int ProgramCounter
+            {
+                get { return pc; }
+                set { pc = value; }
+            }
+            internal InterpreterState(Instruction[] code, int argumentStackSize)
+            {
+                this.code = code;
+                this.pc = 0;
+                if (argumentStackSize > 0)
+                {
+                    this.argumentStack = new double[argumentStackSize];
+                }
+                this.argumentStackPointer = 0;
+            }
+
+            internal void Reset()
+            {
+                this.pc = 0;
+                this.argumentStackPointer = 0;
+            }
+
+            internal Instruction NextInstruction()
+            {
+                return code[pc++];
+            }
+            private void Push(double val)
+            {
+                argumentStack[argumentStackPointer++] = val;
+            }
+            private double Pop()
+            {
+                return argumentStack[--argumentStackPointer];
+            }
+
+            internal void CreateStackFrame(double[] argValues)
+            {
+                // push in reverse order to make indexing easier
+                for (int i = argValues.Length - 1; i >= 0; i--)
+                {
+                    argumentStack[argumentStackPointer++] = argValues[i];
+                }
+                Push(argValues.Length);
+            }
+
+            internal void RemoveStackFrame()
+            {
+                int size = (int)Pop();
+                argumentStackPointer -= size;
+            }
+
+            internal double GetStackFrameValue(ushort index)
+            {
+                // layout of stack:
+                // [0]   <- argumentStackPointer
+                // [StackFrameSize = N + 1]
+                // [Arg0] <- argumentStackPointer - 2 - 0
+                // [Arg1] <- argumentStackPointer - 2 - 1
+                // [...]
+                // [ArgN] <- argumentStackPointer - 2 - N
+                // <Begin of stack frame>
+                return argumentStack[argumentStackPointer - index - 2];
+            }
+        }
+
+        //Operation codes
+        private class OpCodes
+        {
+            public const byte Add = 1;
+            public const byte Sub = 2;
+            public const byte Mul = 3;
+
+            public const byte GT = 5;
+            public const byte LT = 6;
+
+            public const byte AND = 7;
+            public const byte OR = 8;
+            public const byte NOT = 9;
+            public const byte BOOLEAN = 10;
+
+            public const byte Average = 11;
+            public const byte MACD = 12;
+
+            public const byte Variable = 13;
+            public const byte Constant = 14;
+            public const byte ConstantInt = 16;
+            public const byte BoolConstant = 15;
+            public const byte Max = 17;
+            public const byte Min = 18;
+            public const byte Lag = 19;
+            public const byte RSI = 20;
+            public const byte EMA = 21;
+            
+
+        }
+        #endregion
+
+        #region IStatefulItem
+        public void InitializeState()
+        {
+            EvaluatedSolutions.Value = 0;
+        }
+
+        public void ClearState()
+        {
+        }
+        #endregion
+
+        private Dictionary<Type, byte> symbolToOpcode = new Dictionary<Type, byte>() {
+      { typeof(Addition), OpCodes.Add },
+      { typeof(Subtraction), OpCodes.Sub },
+      { typeof(Multiplication), OpCodes.Mul },
+      { typeof(Constant), OpCodes.Constant },
+      { typeof(BoolConstant), OpCodes.BoolConstant },
+      { typeof(ConstantInt), OpCodes.ConstantInt },
+      { typeof(GreaterThan), OpCodes.GT },
+      { typeof(LessThan), OpCodes.LT },
+      { typeof(And), OpCodes.AND },
+      { typeof(Or), OpCodes.OR },
+      { typeof(Not), OpCodes.NOT},
+      { typeof(AverageTrade), OpCodes.Average},
+      { typeof(MACD), OpCodes.MACD},
+      { typeof(RSI), OpCodes.RSI},
+      { typeof(EMA), OpCodes.EMA},
+      { typeof(Max), OpCodes.Max},
+      { typeof(Min), OpCodes.Min},
+      { typeof(Lag), OpCodes.Lag},
+      { typeof(HeuristicLab.Problems.DataAnalysis.Symbolic.Variable), OpCodes.Variable },
+    };
+
+        public override bool CanChangeName
+        {
+            get { return false; }
+        }
+        public override bool CanChangeDescription
+        {
+            get { return false; }
+        }
+
+        #region parameter properties
+        public IValueParameter<BoolValue> CheckExpressionsWithIntervalArithmeticParameter
+        {
+            get { return (IValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; }
+        }
+
+        public IValueParameter<IntValue> EvaluatedSolutionsParameter
+        {
+            get { return (IValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; }
+        }
+        #endregion
+
+        #region properties
+        public BoolValue CheckExpressionsWithIntervalArithmetic
+        {
+            get { return CheckExpressionsWithIntervalArithmeticParameter.Value; }
+            set { CheckExpressionsWithIntervalArithmeticParameter.Value = value; }
+        }
+
+        public IntValue EvaluatedSolutions
+        {
+            get { return EvaluatedSolutionsParameter.Value; }
+            set { EvaluatedSolutionsParameter.Value = value; }
+        }
+        #endregion
+
+
+        
+
+        private double Evaluate(Dataset dataset, ref int row, InterpreterState state)
+        {
+            Instruction currentInstr = state.NextInstruction();
+
+            switch (currentInstr.opCode)
+            {
+                case OpCodes.Add:
+                    {
+                        double s = Evaluate(dataset, ref row, state);
+                        for (int i = 1; i < currentInstr.nArguments; i++)
+                        {
+                            s += Evaluate(dataset, ref row, state);
+                        }
+                        return s;
+                    }
+                case OpCodes.Sub:
+                    {
+                        double s = Evaluate(dataset, ref row, state);
+                        for (int i = 1; i < currentInstr.nArguments; i++)
+                        {
+                            s -= Evaluate(dataset, ref row, state);
+                        }
+                        if (currentInstr.nArguments == 1) s = -s;
+                        return s;
+                    }
+                case OpCodes.Mul:
+                    {
+                        double p = Evaluate(dataset, ref row, state);
+                        for (int i = 1; i < currentInstr.nArguments; i++)
+                        {
+                            p *= Evaluate(dataset, ref row, state);
+                        }
+                        return p;
+                    }
+                case OpCodes.Average:
+                    {
+                        double sum = Evaluate(dataset, ref row, state);
+                        int integerValue = (int) Math.Floor(sum);
+                        if (integerValue > 100) integerValue = 100;
+                        if (row < integerValue)
+                        {
+                            string variableName = dataset.GetValue(row, 2);
+                            double inferiorValue = Convert.ToDouble(variableName);
+                            return inferiorValue/(row+1);
+                        }
+                        else
+                        {
+                            string variableName = dataset.GetValue(row, 2);
+                            double meanValue1 = Convert.ToDouble(variableName);
+                            string variableName2 = dataset.GetValue((row - integerValue), 2);
+                            double meanValue2 = Convert.ToDouble(variableName2);
+                            return (meanValue1 - meanValue2) / integerValue;
+                        }
+                    }
+                case OpCodes.MACD:
+                    {                 
+                        /*double firstMean = Evaluate(dataset, ref row, state);
+                        double secondMean = Evaluate(dataset, ref row, state);
+                        double signal = Evaluate(dataset, ref row, state);
+                        double firstEMA = 0.0;
+                        double secondEMA = 0.0;
+                        double lastFirstEMA = 0.0;
+                        double lastSecondEMA = 0.0;
+                        double macd = 0.0;
+                        double firstFactor = 0.0;
+                        double signalValue = Double.NegativeInfinity;
+                        if (row == (firstMean - 1))
+                        {
+                            string variableName = dataset.GetValue(row, 2);
+                            double meanValue1 = Convert.ToDouble(variableName);
+                            firstEMA = meanValue1 / firstMean;
+                        }
+                        if (row == (secondMean-1))
+                        {
+                            string variableName = dataset.GetValue(row, 2);
+                            double meanValue2 = Convert.ToDouble(variableName);
+                            secondEMA = meanValue2 / secondMean;
+                        }
+                        string variableName2 = dataset.GetValue(row, 1);
+                        double intValue = Convert.ToDouble(variableName2);
+                        if (row > (firstMean-1))
+                        {
+                              firstFactor = 2 / (firstMean + 1);                          
+                              firstEMA = (intValue * firstFactor) + (lastFirstEMA * (1-firstFactor));
+                        }
+                            if (row > (secondMean-1))
+                            {
+                                double secondFactor = 2 / (secondMean + 1);
+                                secondEMA = (intValue * secondFactor) + (lastSecondEMA * (1 - secondFactor));      
+                            }
+                            lastFirstEMA = firstEMA;
+                            lastSecondEMA = secondEMA;
+                            macd = firstEMA - secondEMA;
+                        if ((row < (firstMean-1)) || (row < (secondMean-1))) return 0.0;
+                        else return macd;*/
+                        return 0.0;
+
+                        //macd = firstEMA - secondEMA;
+                        //if (row == Math.Max(firstMean, secondMean)) signalValue = macd;
+                        //if (row > firstMean && row > secondMean)
+                        //{
+                        //    double factor = 2 / (signal + 1);
+                        //    signalValue = (macd * factor) + (lastSignal * (1 - factor));
+                        //}
+                        //if (!Double.IsNegativeInfinity(signalValue)) lastSignal = signalValue;
+                        //return signalValue > macd ? 1.0 : -1.0;
+                    }
+                case OpCodes.AND:
+                    {
+                        double result = Evaluate(dataset, ref row, state);
+                        for (int i = 1; i < currentInstr.nArguments; i++)
+                        {
+                            if (result > 0.0) result = Evaluate(dataset, ref row, state);
+                            else
+                            {
+                                SkipInstructions(state);
+                            }
+                        }
+                        return result > 0.0 ? 1.0 : -1.0;
+                    }
+                case OpCodes.OR:
+                    {
+                        double result = Evaluate(dataset, ref row, state);
+                        for (int i = 1; i < currentInstr.nArguments; i++)
+                        {
+                            if (result <= 0.0) result = Evaluate(dataset, ref row, state);
+                            else
+                            {
+                                SkipInstructions(state);
+                            }
+                        }
+                        return result > 0.0 ? 1.0 : -1.0;
+                    }
+                case OpCodes.NOT:
+                    {
+                        return Evaluate(dataset, ref row, state) > 0.0 ? -1.0 : 1.0;
+                    }
+
+                case OpCodes.BOOLEAN:
+                    {
+                        var booleanTreeNode = currentInstr.dynamicNode as BoolConstantTreeNode;
+                        return booleanTreeNode.Value;
+                    }
+                case OpCodes.GT:
+                    {
+                        double x = Evaluate(dataset, ref row, state);
+                        double y = Evaluate(dataset, ref row, state);
+                        if (x > y) return 1.0;
+                        else return -1.0;
+                    }
+                case OpCodes.LT:
+                    {
+                        double x = Evaluate(dataset, ref row, state);
+                        double y = Evaluate(dataset, ref row, state);
+                        if (x < y) return 1.0;
+                        else return -1.0;
+                    }
+                case OpCodes.Variable:
+                    {
+                        if (row < 0 || row >= dataset.Rows)
+                            return double.NaN;
+                        var variableTreeNode = (VariableTreeNode)currentInstr.dynamicNode;
+                        return ((IList<double>)currentInstr.iArg0)[row] * variableTreeNode.Weight;
+                    }
+                case OpCodes.EMA:
+                    {
+                        double timeValue = Evaluate(dataset, ref row, state);
+                        if (EMAValue == null || EMAValue.GetLength(0) < dataset.Rows)
+                            EMAValue = dataset.GetDoubleValues("Close").ToArray();
+                        int lastRow = row - 1;
+                        EMAValue[row] = double.NaN;
+                        if (row == (timeValue - 1))
+                        {
+                            string variableName = dataset.GetValue(row, 2);
+                            double meanValue = Convert.ToDouble(variableName);
+                            EMAValue[row] = meanValue / timeValue;
+                        }
+                        if (row > (timeValue - 1))
+                        {
+                            lastValue = ((IList<double>)currentInstr.iArg0)[row];
+                            string variableName = dataset.GetValue(row, 1);
+                            double meanValue = Convert.ToDouble(variableName);
+                            double factor = 2 / (timeValue + 1);
+                            EMAValue[row] = (meanValue * factor) + (EMAValue[lastRow] * (1 - factor));
+                        }
+                        return EMAValue[row];
+
+
+                    }
+                case OpCodes.Constant:
+                    {
+                        var constTreeNode = currentInstr.dynamicNode as ConstantTreeNode;
+                        return constTreeNode.Value;
+                    }
+                case OpCodes.BoolConstant:
+                    {
+                        var boolConstTreeNode = currentInstr.dynamicNode as BoolConstantTreeNode;
+                        return boolConstTreeNode.Value;
+                    }
+                case OpCodes.ConstantInt:
+                    {
+                        var constIntTreeNode = currentInstr.dynamicNode as ConstantIntTreeNode;
+                        return constIntTreeNode.Value;
+                    }
+                case OpCodes.Max:
+                    {
+                        int n = (int) Evaluate(dataset, ref row, state);
+                        double max = Double.NegativeInfinity;
+                        int i = Math.Min(n,row);
+                        while(i>=0)
+                        {
+                            int position = row - i;
+                            string variableName = dataset.GetValue(position, 1);
+                            double intValue = Convert.ToDouble(variableName);
+                            if (intValue>max) max = intValue;
+                        i--;
+                        }
+                        return max;
+                    }
+                case OpCodes.Min:
+                    {
+                        int n = (int)Evaluate(dataset, ref row, state);
+                        double min = Double.NegativeInfinity;
+                        int i = Math.Min(n, row);
+                        while (i >= 0)
+                        {
+                            int position = row - i;
+                            string variableName = dataset.GetValue(position, 1);
+                            double intValue = Convert.ToDouble(variableName);
+                            if (intValue < min) min = intValue;
+                            i--;
+                        }
+                          return min;
+                    }
+                case OpCodes.Lag:
+                    {
+                        int n = (int) Evaluate(dataset, ref row, state);
+                        if (n>row) return 0;
+                        int position = row - n;
+                        string variableName = dataset.GetValue(position, 1);
+                        double intValue = Convert.ToDouble(variableName);
+                        return intValue;
+                    }
+                case OpCodes.RSI:
+                    {
+                        /*
+                        double numberOfDays = Evaluate(dataset, ref row, state);
+                        double todayRSI=0.0;
+                        if (numberOfDays > row) return 0.0;
+                        else
+                        {
+                            double addUp = 0;
+                            double addDown = 0;
+                            double change=0;
+                            if (row == (numberOfDays))
+                            {
+                                for (int k = 1; k < (numberOfDays+1); k++)
+                                {
+                                    string variableName = dataset.GetValue(k, 1);
+                                    double intValue = Convert.ToDouble(variableName);
+                                    variableName = dataset.GetValue((k - 1), 1);
+                                    double intValue2 = Convert.ToDouble(variableName);
+                                     change = intValue - intValue2;
+                                    if (change > 0) addUp = addUp + change;
+                                    else addDown = addDown - change;
+                                  
+                                }
+                                meanUp = addUp / numberOfDays;
+                                meanDown = addDown / numberOfDays;
+                                if (meanDown != 0) todayRSI = 100 - (100 / (1 + (meanUp / meanDown)));
+                                else todayRSI = 100;
+                             }
+                            else
+                            {
+                                string variableName = dataset.GetValue(row, 1);
+                                double intValue = Convert.ToDouble(variableName);
+                                variableName = dataset.GetValue((row - 1), 1);
+                                double intValue2 = Convert.ToDouble(variableName);
+                                change = intValue - intValue2;
+
+                                addUp = meanUp * (numberOfDays - 1);
+                                addDown = meanDown * (numberOfDays - 1);
+                                if (change > 0) addUp = addUp + change;
+                                else addDown = addDown - change;
+                                meanUp = addUp / numberOfDays;
+                                meanDown = addDown / numberOfDays;
+                                if (meanDown != 0) todayRSI = 100 - (100 / (1 + (meanUp / meanDown)));
+                                else todayRSI = 100;
+                            }
+                        }
+                        if ((lastRSI < 70) && (todayRSI >= 70)) inOut = 1;
+                        else if((lastRSI > 30) && (todayRSI <= 30)) inOut=-1;
+                        lastRSI = todayRSI;*/
+                        return 0.0;
+                        
+                    }
+                
+                default: throw new NotSupportedException();
+            }
+        }
+
+        private byte MapSymbolToOpCode(ISymbolicExpressionTreeNode treeNode)
+        {
+            if (symbolToOpcode.ContainsKey(treeNode.Symbol.GetType()))
+                return symbolToOpcode[treeNode.Symbol.GetType()];
+            else
+                throw new NotSupportedException("Symbol: " + treeNode.Symbol);
+        }
+
+        // skips a whole branch
+        private void SkipInstructions(InterpreterState state)
+        {
+            int i = 1;
+            while (i > 0)
+            {
+                i += state.NextInstruction().nArguments;
+                i--;
+            }
+        }
+        [StorableConstructor]
+        private Interpreter(bool deserializing) : base(deserializing) { }
+        private Interpreter(Interpreter original, Cloner cloner) : base(original, cloner) { }
+        public override IDeepCloneable Clone(Cloner cloner)
+        {
+            return new Interpreter(this, cloner);
+        }
+
+        public Interpreter()
+            : base("SymbolicDataAnalysisExpressionTreeInterpreter", "Interpreter for symbolic expression trees including automatically defined functions.")
+        {
+            Parameters.Add(new ValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false)));
+            Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));
+        }
+
+        [StorableHook(HookType.AfterDeserialization)]
+        private void AfterDeserialization()
+        {
+            if (!Parameters.ContainsKey(EvaluatedSolutionsParameterName))
+                Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));
+        }
+        
+        //Take the symbolic expression values of the tree
+        public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, Dataset dataset, IEnumerable<int> rows)
+        {
+            if (CheckExpressionsWithIntervalArithmetic.Value)
+                throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter.");
+            EvaluatedSolutions.Value++; // increment the evaluated solutions counter
+            var compiler = new SymbolicExpressionTreeCompiler();
+            Instruction[] code = compiler.Compile(tree, MapSymbolToOpCode);//Take the type of symbol
+            int necessaryArgStackSize = 0;
+            for (int i = 0; i < code.Length; i++)
+            {
+                Instruction instr = code[i];
+                if (instr.opCode == OpCodes.Variable)
+                {
+                    var variableTreeNode = instr.dynamicNode as VariableTreeNode;
+                    instr.iArg0 = dataset.GetReadOnlyDoubleValues(variableTreeNode.VariableName);
+                    code[i] = instr;
+                }
+                else if (instr.opCode == OpCodes.EMA)
+                {
+                    instr.iArg0 = EMAValue;
+                }
+            }
+            var state = new InterpreterState(code, necessaryArgStackSize);
+            //Evaluate each row of the datase
+            foreach (var rowEnum in rows)
+            {
+                int row = rowEnum;
+                state.Reset();
+                yield return Evaluate(dataset, ref row, state);
+            }
+        }
+
+    }
+}
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/Lag.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/Lag.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/Lag.cs	(revision 9139)
@@ -0,0 +1,34 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Common;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    class Lag : Symbol
+    {
+        private const int minimumArity = 1;
+        private const int maximumArity = 1;
+
+        public override int MinimumArity
+        {
+            get { return minimumArity; }
+        }
+        public override int MaximumArity
+        {
+            get { return maximumArity; }
+        }
+
+        [StorableConstructor]
+        private Lag(bool deserializing) : base(deserializing) { }
+        private Lag(Lag original, Cloner cloner) : base(original, cloner) { }
+        public override IDeepCloneable Clone(Cloner cloner)
+        {
+            return new Lag(this, cloner);
+        }
+        public Lag() : base("Lag", "Symbol that represents the Lag value in a time") { }
+    }
+}
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/MACD.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/MACD.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/MACD.cs	(revision 9139)
@@ -0,0 +1,38 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Core;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Common;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    [StorableClass]
+    [Item("MACD", "Symbol that represents the MACD indicator.")]
+    class MACD : Symbol
+    {
+        private const int minimumArity = 3;
+        private const int maximumArity = 3;
+
+        public override int MinimumArity
+        {
+            get { return minimumArity; }
+        }
+        public override int MaximumArity
+        {
+            get { return maximumArity; }
+        }
+
+        [StorableConstructor]
+        private MACD(bool deserializing) : base(deserializing) { }
+        private MACD(MACD original, Cloner cloner) : base(original, cloner) { }
+        public override IDeepCloneable Clone(Cloner cloner)
+        {
+            return new MACD(this, cloner);
+        }
+        public MACD() : base("MACD", "Symbol that represents the MACD indicator.") { }
+    }
+
+ }
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/Max.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/Max.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/Max.cs	(revision 9139)
@@ -0,0 +1,35 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Common;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    class Max :Symbol
+    {
+        private const int minimumArity = 1;
+        private const int maximumArity = 1;
+
+        public override int MinimumArity
+        {
+            get { return minimumArity; }
+        }
+        public override int MaximumArity
+        {
+            get { return maximumArity; }
+        }
+
+        [StorableConstructor]
+        private Max(bool deserializing) : base(deserializing) { }
+        private Max(Max original, Cloner cloner) : base(original, cloner) { }
+        public override IDeepCloneable Clone(Cloner cloner)
+        {
+            return new Max(this, cloner);
+        }
+        public Max() : base("Max", "Symbol that represents the Max value in a time") { }
+    }
+ }
+
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/Min.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/Min.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/Min.cs	(revision 9139)
@@ -0,0 +1,34 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Common;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    class Min : Symbol
+    {
+        private const int minimumArity = 1;
+        private const int maximumArity = 1;
+
+        public override int MinimumArity
+        {
+            get { return minimumArity; }
+        }
+        public override int MaximumArity
+        {
+            get { return maximumArity; }
+        }
+
+        [StorableConstructor]
+        private Min(bool deserializing) : base(deserializing) { }
+        private Min(Min original, Cloner cloner) : base(original, cloner) { }
+        public override IDeepCloneable Clone(Cloner cloner)
+        {
+            return new Min(this, cloner);
+        }
+        public Min() : base("Min", "Symbol that represents the Min value in a time") { }
+    }
+}
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/Plugin.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/Plugin.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/Plugin.cs	(revision 9139)
@@ -0,0 +1,26 @@
+﻿using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    [Plugin("HeuristicLab.Problems.TradeRules", "Trade rules problem for genetic programming", "1.0.0")]
+    [PluginFile("HeuristicLab.Problems.TradeRules-1.0.dll", PluginFileType.Assembly)]
+    [PluginDependency("HeuristicLab.Data", "3.3")]
+    [PluginDependency("HeuristicLab.Core", "3.3")]
+    [PluginDependency("HeuristicLab.Common", "3.3")]
+    [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")]
+    [PluginDependency("HeuristicLab.Collections", "3.3")]
+    [PluginDependency("HeuristicLab.Operators", "3.3")]
+    [PluginDependency("HeuristicLab.Operators.Programmable", "3.3")]
+    [PluginDependency("HeuristicLab.Optimization", "3.3")]
+    [PluginDependency("HeuristicLab.Optimizer", "3.3")]
+    [PluginDependency("HeuristicLab.Parameters", "3.3")]
+    [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
+    [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic", "3.4")]
+    [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression", "3.4")]
+    [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
+    [PluginDependency("HeuristicLab.Random", "3.3")]
+    [PluginDependency("HeuristicLab.Persistence", "3.3")]
+    public class Plugin : PluginBase
+    {
+    }
+}
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/Properties/HeuristicLab.Problems.TradeRules-1.0.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/Properties/HeuristicLab.Problems.TradeRules-1.0.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/Properties/HeuristicLab.Problems.TradeRules-1.0.cs	(revision 9139)
@@ -0,0 +1,36 @@
+﻿using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// La información general sobre un ensamblado se controla mediante el siguiente 
+// conjunto de atributos. Cambie estos atributos para modificar la información
+// asociada con un ensamblado.
+[assembly: AssemblyTitle("HeuristicLab.Problems.TradeRules")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Mi casa")]
+[assembly: AssemblyProduct("HeuristicLab.Problems.TradeRules")]
+[assembly: AssemblyCopyright("Copyright © Mi casa 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Si establece ComVisible como false, los tipos de este ensamblado no estarán visibles 
+// para los componentes COM. Si necesita obtener acceso a un tipo de este ensamblado desde 
+// COM, establezca el atributo ComVisible como true en este tipo.
+[assembly: ComVisible(false)]
+
+// El siguiente GUID sirve como identificador de typelib si este proyecto se expone a COM
+[assembly: Guid("5f7df907-cbcb-42a5-9c77-a03becf45c59")]
+
+// La información de versión de un ensamblado consta de los cuatro valores siguientes:
+//
+//      Versión principal
+//      Versión secundaria 
+//      Número de compilación
+//      Revisión
+//
+// Puede especificar todos los valores o establecer como predeterminados los números de versión de compilación y de revisión 
+// mediante el asterisco ('*'), como se muestra a continuación:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/RSI.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/RSI.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/RSI.cs	(revision 9139)
@@ -0,0 +1,35 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Common;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    class RSI: Symbol
+    {
+        private const int minimumArity = 1;
+        private const int maximumArity = 1;
+
+        public override int MinimumArity
+        {
+            get { return minimumArity; }
+        }
+        public override int MaximumArity
+        {
+            get { return maximumArity; }
+        }
+
+        [StorableConstructor]
+        private RSI(bool deserializing) : base(deserializing) { }
+        private RSI(RSI original, Cloner cloner) : base(original, cloner) { }
+        public override IDeepCloneable Clone(Cloner cloner)
+        {
+            return new RSI(this, cloner);
+        }
+        public RSI() : base("RSI", "Symbol that represents the RSI indicator.") { }
+    
+    }
+}
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/TradeAnalysisProblem.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/TradeAnalysisProblem.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/TradeAnalysisProblem.cs	(revision 9139)
@@ -0,0 +1,390 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Drawing;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Common.Resources;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Problems.Instances;
+using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Problems.DataAnalysis.Symbolic;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    [StorableClass]
+    public abstract class TradeAnalysisProblem<T, U, V> : HeuristicOptimizationProblem<U, V>, IDataAnalysisProblem<T>, ISymbolicDataAnalysisProblem, IStorableContent,
+      IProblemInstanceConsumer<T>, IProblemInstanceExporter<T>
+        where T : class, IDataAnalysisProblemData
+        where U : class, ISymbolicDataAnalysisEvaluator<T>
+        where V : class, ISymbolicDataAnalysisSolutionCreator
+    {
+
+        #region parameter names & descriptions
+        private const string ProblemDataParameterName = "ProblemData";
+        private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
+        private const string SymbolicExpressionTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter";
+        private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
+        private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
+        private const string MaximumFunctionDefinitionsParameterName = "MaximumFunctionDefinitions";
+        private const string MaximumFunctionArgumentsParameterName = "MaximumFunctionArguments";
+        private const string RelativeNumberOfEvaluatedSamplesParameterName = "RelativeNumberOfEvaluatedSamples";
+        private const string FitnessCalculationPartitionParameterName = "FitnessCalculationPartition";
+        private const string ValidationPartitionParameterName = "ValidationPartition";
+
+        private const string ProblemDataParameterDescription = "";
+        private const string SymbolicExpressionTreeGrammarParameterDescription = "The grammar that should be used for symbolic expression tree.";
+        private const string SymoblicExpressionTreeInterpreterParameterDescription = "The interpreter that should be used to evaluate the symbolic expression tree.";
+        private const string MaximumSymbolicExpressionTreeDepthParameterDescription = "Maximal depth of the symbolic expression. The minimum depth needed for the algorithm is 3 because two levels are reserved for the ProgramRoot and the Start symbol.";
+        private const string MaximumSymbolicExpressionTreeLengthParameterDescription = "Maximal length of the symbolic expression.";
+        private const string MaximumFunctionDefinitionsParameterDescription = "Maximal number of automatically defined functions";
+        private const string MaximumFunctionArgumentsParameterDescription = "Maximal number of arguments of automatically defined functions.";
+        private const string RelativeNumberOfEvaluatedSamplesParameterDescription = "The relative number of samples of the dataset partition, which should be randomly chosen for evaluation.";
+        private const string FitnessCalculationPartitionParameterDescription = "The partition of the problem data training partition, that should be used to calculate the fitness of an individual.";
+        private const string ValidationPartitionParameterDescription = "The partition of the problem data training partition, that should be used to select the best model from (optional).";
+        #endregion
+
+        #region parameter properties
+        IParameter IDataAnalysisProblem.ProblemDataParameter
+        {
+            get { return ProblemDataParameter; }
+        }
+        public IValueParameter<T> ProblemDataParameter
+        {
+            get { return (IValueParameter<T>)Parameters[ProblemDataParameterName]; }
+        }
+        public IValueParameter<ISymbolicDataAnalysisGrammar> SymbolicExpressionTreeGrammarParameter
+        {
+            get { return (IValueParameter<ISymbolicDataAnalysisGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; }
+        }
+        public IValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter
+        {
+            get { return (IValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; }
+        }
+        public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter
+        {
+            get { return (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
+        }
+        public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter
+        {
+            get { return (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
+        }
+        public IFixedValueParameter<IntValue> MaximumFunctionDefinitionsParameter
+        {
+            get { return (IFixedValueParameter<IntValue>)Parameters[MaximumFunctionDefinitionsParameterName]; }
+        }
+        public IFixedValueParameter<IntValue> MaximumFunctionArgumentsParameter
+        {
+            get { return (IFixedValueParameter<IntValue>)Parameters[MaximumFunctionArgumentsParameterName]; }
+        }
+        public IFixedValueParameter<PercentValue> RelativeNumberOfEvaluatedSamplesParameter
+        {
+            get { return (IFixedValueParameter<PercentValue>)Parameters[RelativeNumberOfEvaluatedSamplesParameterName]; }
+        }
+        public IFixedValueParameter<IntRange> FitnessCalculationPartitionParameter
+        {
+            get { return (IFixedValueParameter<IntRange>)Parameters[FitnessCalculationPartitionParameterName]; }
+        }
+        public IFixedValueParameter<IntRange> ValidationPartitionParameter
+        {
+            get { return (IFixedValueParameter<IntRange>)Parameters[ValidationPartitionParameterName]; }
+        }
+        #endregion
+
+        #region properties
+        public string Filename { get; set; }
+        public static new Image StaticItemImage { get { return VSImageLibrary.Type; } }
+
+        IDataAnalysisProblemData IDataAnalysisProblem.ProblemData
+        {
+            get { return ProblemData; }
+        }
+        public T ProblemData
+        {
+            get { return ProblemDataParameter.Value; }
+            set { ProblemDataParameter.Value = value; }
+        }
+
+        public ISymbolicDataAnalysisGrammar SymbolicExpressionTreeGrammar
+        {
+            get { return SymbolicExpressionTreeGrammarParameter.Value; }
+            set { SymbolicExpressionTreeGrammarParameter.Value = value; }
+        }
+        public ISymbolicDataAnalysisExpressionTreeInterpreter SymbolicExpressionTreeInterpreter
+        {
+            get { return SymbolicExpressionTreeInterpreterParameter.Value; }
+            set { SymbolicExpressionTreeInterpreterParameter.Value = value; }
+        }
+
+        public IntValue MaximumSymbolicExpressionTreeDepth
+        {
+            get { return MaximumSymbolicExpressionTreeDepthParameter.Value; }
+        }
+        public IntValue MaximumSymbolicExpressionTreeLength
+        {
+            get { return MaximumSymbolicExpressionTreeLengthParameter.Value; }
+        }
+        public IntValue MaximumFunctionDefinitions
+        {
+            get { return MaximumFunctionDefinitionsParameter.Value; }
+        }
+        public IntValue MaximumFunctionArguments
+        {
+            get { return MaximumFunctionArgumentsParameter.Value; }
+        }
+        public PercentValue RelativeNumberOfEvaluatedSamples
+        {
+            get { return RelativeNumberOfEvaluatedSamplesParameter.Value; }
+        }
+
+        public IntRange FitnessCalculationPartition
+        {
+            get { return FitnessCalculationPartitionParameter.Value; }
+        }
+        public IntRange ValidationPartition
+        {
+            get { return ValidationPartitionParameter.Value; }
+        }
+        #endregion
+
+        [StorableConstructor]
+        protected TradeAnalysisProblem(bool deserializing) : base(deserializing) { }
+        [StorableHook(HookType.AfterDeserialization)]
+        private void AfterDeserialization()
+        {
+            RegisterEventHandlers();
+        }
+        protected TradeAnalysisProblem(TradeAnalysisProblem<T, U, V> original, Cloner cloner)
+            : base(original, cloner)
+        {
+            RegisterEventHandlers();
+        }
+
+        protected TradeAnalysisProblem(T problemData, U evaluator, V solutionCreator)
+            : base(evaluator, solutionCreator)
+        {
+            Parameters.Add(new ValueParameter<T>(ProblemDataParameterName, ProblemDataParameterDescription, problemData));
+            Parameters.Add(new ValueParameter<ISymbolicDataAnalysisGrammar>(SymbolicExpressionTreeGrammarParameterName, SymbolicExpressionTreeGrammarParameterDescription));
+            Parameters.Add(new ValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, SymoblicExpressionTreeInterpreterParameterDescription));
+            Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, MaximumSymbolicExpressionTreeDepthParameterDescription));
+            Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, MaximumSymbolicExpressionTreeLengthParameterDescription));
+            Parameters.Add(new FixedValueParameter<IntValue>(MaximumFunctionDefinitionsParameterName, MaximumFunctionDefinitionsParameterDescription));
+            Parameters.Add(new FixedValueParameter<IntValue>(MaximumFunctionArgumentsParameterName, MaximumFunctionArgumentsParameterDescription));
+            Parameters.Add(new FixedValueParameter<IntRange>(FitnessCalculationPartitionParameterName, FitnessCalculationPartitionParameterDescription));
+            Parameters.Add(new FixedValueParameter<IntRange>(ValidationPartitionParameterName, ValidationPartitionParameterDescription));
+            Parameters.Add(new FixedValueParameter<PercentValue>(RelativeNumberOfEvaluatedSamplesParameterName, RelativeNumberOfEvaluatedSamplesParameterDescription, new PercentValue(1)));
+
+            SymbolicExpressionTreeInterpreterParameter.Hidden = true;
+            MaximumFunctionArgumentsParameter.Hidden = true;
+            MaximumFunctionDefinitionsParameter.Hidden = true;
+
+            SymbolicExpressionTreeGrammar = new Grammar();
+            SymbolicExpressionTreeInterpreter = new Interpreter();
+
+            FitnessCalculationPartition.Start = ProblemData.TrainingPartition.Start;
+            FitnessCalculationPartition.End = ProblemData.TrainingPartition.End;
+
+            InitializeOperators();
+
+            UpdateGrammar();
+            RegisterEventHandlers();
+        }
+
+        protected virtual void UpdateGrammar()
+        {
+            SymbolicExpressionTreeGrammar.MaximumFunctionArguments = MaximumFunctionArguments.Value;
+            SymbolicExpressionTreeGrammar.MaximumFunctionDefinitions = MaximumFunctionDefinitions.Value;
+            foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Variable>())
+            {
+                if (!varSymbol.Fixed) varSymbol.VariableNames = ProblemData.AllowedInputVariables;
+            }
+            foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.VariableCondition>())
+            {
+                if (!varSymbol.Fixed) varSymbol.VariableNames = ProblemData.AllowedInputVariables;
+            }
+        }
+
+        private void InitializeOperators()
+        {
+            Operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>());
+            Operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicDataAnalysisExpressionCrossover<T>>());
+            Operators.Add(new SymbolicExpressionSymbolFrequencyAnalyzer());
+            Operators.Add(new SymbolicDataAnalysisVariableFrequencyAnalyzer());
+            Operators.Add(new MinAverageMaxSymbolicExpressionTreeLengthAnalyzer());
+            Operators.Add(new SymbolicExpressionTreeLengthAnalyzer());
+            ParameterizeOperators();
+        }
+
+        #region events
+        private void RegisterEventHandlers()
+        {
+            ProblemDataParameter.ValueChanged += new EventHandler(ProblemDataParameter_ValueChanged);
+            ProblemDataParameter.Value.Changed += (object sender, EventArgs e) => OnProblemDataChanged();
+
+            SymbolicExpressionTreeGrammarParameter.ValueChanged += new EventHandler(SymbolicExpressionTreeGrammarParameter_ValueChanged);
+
+            MaximumFunctionArguments.ValueChanged += new EventHandler(ArchitectureParameterValue_ValueChanged);
+            MaximumFunctionDefinitions.ValueChanged += new EventHandler(ArchitectureParameterValue_ValueChanged);
+            MaximumSymbolicExpressionTreeDepth.ValueChanged += new EventHandler(MaximumSymbolicExpressionTreeDepth_ValueChanged);
+        }
+
+        private void ProblemDataParameter_ValueChanged(object sender, EventArgs e)
+        {
+            ValidationPartition.Start = 0;
+            ValidationPartition.End = 0;
+            ProblemDataParameter.Value.Changed += (object s, EventArgs args) => OnProblemDataChanged();
+            OnProblemDataChanged();
+        }
+
+        private void SymbolicExpressionTreeGrammarParameter_ValueChanged(object sender, EventArgs e)
+        {
+            UpdateGrammar();
+        }
+
+        private void ArchitectureParameterValue_ValueChanged(object sender, EventArgs e)
+        {
+            UpdateGrammar();
+        }
+
+        private void MaximumSymbolicExpressionTreeDepth_ValueChanged(object sender, EventArgs e)
+        {
+            if (MaximumSymbolicExpressionTreeDepth != null && MaximumSymbolicExpressionTreeDepth.Value < 3)
+                MaximumSymbolicExpressionTreeDepth.Value = 3;
+        }
+
+        protected override void OnSolutionCreatorChanged()
+        {
+            base.OnSolutionCreatorChanged();
+            SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
+            ParameterizeOperators();
+        }
+
+        private void SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e)
+        {
+            ParameterizeOperators();
+        }
+
+        protected override void OnEvaluatorChanged()
+        {
+            base.OnEvaluatorChanged();
+            ParameterizeOperators();
+        }
+
+        public event EventHandler ProblemDataChanged;
+        protected virtual void OnProblemDataChanged()
+        {
+            FitnessCalculationPartition.Start = ProblemData.TrainingPartition.Start;
+            FitnessCalculationPartition.End = ProblemData.TrainingPartition.End;
+
+            UpdateGrammar();
+            ParameterizeOperators();
+
+            var handler = ProblemDataChanged;
+            if (handler != null) handler(this, EventArgs.Empty);
+
+            OnReset();
+        }
+        #endregion
+
+        protected virtual void ParameterizeOperators()
+        {
+            var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators).ToList();
+
+            foreach (var op in operators.OfType<ISymbolicExpressionTreeGrammarBasedOperator>())
+            {
+                op.SymbolicExpressionTreeGrammarParameter.ActualName = SymbolicExpressionTreeGrammarParameterName;
+            }
+            foreach (var op in operators.OfType<ISymbolicExpressionTreeSizeConstraintOperator>())
+            {
+                op.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaximumSymbolicExpressionTreeDepthParameterName;
+                op.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameterName;
+            }
+            foreach (var op in operators.OfType<ISymbolicExpressionTreeArchitectureAlteringOperator>())
+            {
+                op.MaximumFunctionArgumentsParameter.ActualName = MaximumFunctionArgumentsParameterName;
+                op.MaximumFunctionDefinitionsParameter.ActualName = MaximumFunctionDefinitionsParameterName;
+            }
+            foreach (var op in operators.OfType<ISymbolicDataAnalysisEvaluator<T>>())
+            {
+                op.ProblemDataParameter.ActualName = ProblemDataParameterName;
+                op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
+                op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name;
+                op.RelativeNumberOfEvaluatedSamplesParameter.ActualName = RelativeNumberOfEvaluatedSamplesParameter.Name;
+            }
+            foreach (var op in operators.OfType<ISymbolicExpressionTreeCrossover>())
+            {
+                op.ParentsParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
+                op.ChildParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
+            }
+            foreach (var op in operators.OfType<ISymbolicExpressionTreeManipulator>())
+            {
+                op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
+            }
+            foreach (var op in operators.OfType<ISymbolicExpressionTreeAnalyzer>())
+            {
+                op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
+            }
+            foreach (var op in operators.OfType<ISymbolicDataAnalysisAnalyzer>())
+            {
+                op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
+            }
+            foreach (var op in operators.OfType<ISymbolicDataAnalysisValidationAnalyzer<U, T>>())
+            {
+                op.RelativeNumberOfEvaluatedSamplesParameter.ActualName = RelativeNumberOfEvaluatedSamplesParameter.Name;
+                op.ValidationPartitionParameter.ActualName = ValidationPartitionParameter.Name;
+            }
+            foreach (var op in operators.OfType<ISymbolicDataAnalysisInterpreterOperator>())
+            {
+                op.SymbolicDataAnalysisTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameterName;
+            }
+            foreach (var op in operators.OfType<ISymbolicDataAnalysisExpressionCrossover<T>>())
+            {
+                op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameterName;
+                op.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
+                op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name;
+                op.RelativeNumberOfEvaluatedSamplesParameter.ActualName = RelativeNumberOfEvaluatedSamplesParameter.Name;
+                op.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
+            }
+        }
+
+        #region Import & Export
+        public void Load(T data)
+        {
+            Name = data.Name;
+            Description = data.Description;
+            ProblemData = data;
+            OnReset();
+        }
+
+        public T Export()
+        {
+            return ProblemData;
+        }
+        #endregion
+    }
+}
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/TradeRulesAbstractProblem.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/TradeRulesAbstractProblem.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/TradeRulesAbstractProblem.cs	(revision 9139)
@@ -0,0 +1,139 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.DataAnalysis.Symbolic;
+using HeuristicLab.Problems.DataAnalysis;
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    [StorableClass]
+    public abstract class TradeRulesAbstractProblem<T, U, V> : TradeAnalysisProblem<T, U, V>, ISingleObjectiveHeuristicOptimizationProblem
+        where T : class,IDataAnalysisProblemData
+        where U : class, ISymbolicDataAnalysisSingleObjectiveEvaluator<T>
+        where V : class, ISymbolicDataAnalysisSolutionCreator
+    {
+        private const string MaximizationParameterName = "Maximization";
+        private const string BestKnownQualityParameterName = "BestKnownQuality";
+
+        #region parameter properties
+        public IFixedValueParameter<BoolValue> MaximizationParameter
+        {
+            get { return (IFixedValueParameter<BoolValue>)Parameters[MaximizationParameterName]; }
+        }
+        IParameter ISingleObjectiveHeuristicOptimizationProblem.MaximizationParameter
+        {
+            get { return MaximizationParameter; }
+        }
+        public IFixedValueParameter<DoubleValue> BestKnownQualityParameter
+        {
+            get { return (IFixedValueParameter<DoubleValue>)Parameters[BestKnownQualityParameterName]; }
+        }
+        IParameter ISingleObjectiveHeuristicOptimizationProblem.BestKnownQualityParameter
+        {
+            get { return BestKnownQualityParameter; }
+        }
+        #endregion
+
+        #region properties
+        public BoolValue Maximization
+        {
+            get { return MaximizationParameter.Value; }
+        }
+        public DoubleValue BestKnownQuality
+        {
+            get { return BestKnownQualityParameter.Value; }
+        }
+        ISingleObjectiveEvaluator ISingleObjectiveHeuristicOptimizationProblem.Evaluator
+        {
+            get { return Evaluator; }
+        }
+        #endregion
+
+        [StorableConstructor]
+        protected TradeRulesAbstractProblem(bool deserializing) : base(deserializing) { }
+        protected TradeRulesAbstractProblem(TradeRulesAbstractProblem<T, U, V> original, Cloner cloner)
+            : base(original, cloner)
+        {
+            RegisterEventHandler();
+            MaximizationParameter.Hidden = true;
+        }
+
+        public TradeRulesAbstractProblem(T problemData, U evaluator, V solutionCreator)
+            : base(problemData, evaluator, solutionCreator)
+        {
+            Parameters.Add(new FixedValueParameter<BoolValue>(MaximizationParameterName, "Set to false if the problem should be minimized."));
+            Parameters.Add(new FixedValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem."));
+
+            MaximizationParameter.Hidden = true;
+            InitializeOperators();
+            RegisterEventHandler();
+        }
+
+        [StorableHook(HookType.AfterDeserialization)]
+        private void AfterDeserialization()
+        {
+            RegisterEventHandler();
+        }
+
+        private void InitializeOperators()
+        {
+            Operators.Add(new SymbolicDataAnalysisAlleleFrequencyAnalyzer());
+            ParameterizeOperators();
+        }
+
+        private void RegisterEventHandler()
+        {
+            Evaluator.QualityParameter.ActualNameChanged += new EventHandler(QualityParameter_ActualNameChanged);
+        }
+
+        protected override void OnEvaluatorChanged()
+        {
+            base.OnEvaluatorChanged();
+            Evaluator.QualityParameter.ActualNameChanged += new EventHandler(QualityParameter_ActualNameChanged);
+            Maximization.Value = base.Evaluator.Maximization;
+            ParameterizeOperators();
+        }
+
+        private void QualityParameter_ActualNameChanged(object sender, EventArgs e)
+        {
+            ParameterizeOperators();
+        }
+
+        protected override void ParameterizeOperators()
+        {
+            base.ParameterizeOperators();
+
+            foreach (var op in Operators.OfType<ISymbolicDataAnalysisSingleObjectiveAnalyzer>())
+            {
+                op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
+                op.MaximizationParameter.ActualName = MaximizationParameterName;
+            }
+        }
+    }
+}
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/TradeRulesProblem.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/TradeRulesProblem.cs	(revision 9139)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/TradeRulesProblem.cs	(revision 9139)
@@ -0,0 +1,164 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.DataAnalysis.Symbolic;
+using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 
+ 
+
+namespace HeuristicLab.Problems.TradeRules
+{
+    [Item("TradeRules", "Represents a trade rules in a symbolic regression problem.")]
+    [StorableClass]
+    [Creatable("Problems")]
+    public class TradeRulesProblem : TradeRulesAbstractProblem<IRegressionProblemData, ISymbolicRegressionSingleObjectiveEvaluator, ISymbolicDataAnalysisSolutionCreator>, IRegressionProblem
+    {
+        private const double PunishmentFactor = 10;
+        private const int InitialMaximumTreeDepth = 8;
+        private const int InitialMaximumTreeLength = 25;
+        private const string EstimationLimitsParameterName = "EstimationLimits";
+        private const string EstimationLimitsParameterDescription = "The limits for the estimated value that can be returned by the symbolic regression model.";
+
+        #region parameter properties
+        public IFixedValueParameter<DoubleLimit> EstimationLimitsParameter
+        {
+            get { return (IFixedValueParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; }
+        }
+        #endregion
+        #region properties
+        public DoubleLimit EstimationLimits
+        {
+            get { return EstimationLimitsParameter.Value; }
+        }
+        #endregion
+        [StorableConstructor]
+        protected TradeRulesProblem(bool deserializing) : base(deserializing) { }
+        protected TradeRulesProblem(TradeRulesProblem original, Cloner cloner)
+            : base(original, cloner)
+        {
+            RegisterEventHandlers();
+        }
+        public override IDeepCloneable Clone(Cloner cloner) { return new TradeRulesProblem(this, cloner); }
+
+        public TradeRulesProblem()
+            : base(new RegressionProblemData(), new EvaluatorTradeRules(), new SymbolicDataAnalysisExpressionTreeCreator())
+        {
+            Parameters.Add(new FixedValueParameter<DoubleLimit>(EstimationLimitsParameterName, EstimationLimitsParameterDescription));
+
+            EstimationLimitsParameter.Hidden = true;
+
+            Maximization.Value = true;
+            MaximumSymbolicExpressionTreeDepth.Value = InitialMaximumTreeDepth;
+            MaximumSymbolicExpressionTreeLength.Value = InitialMaximumTreeLength;
+
+            RegisterEventHandlers();
+            ConfigureGrammarSymbols();
+            InitializeOperators();
+            UpdateEstimationLimits();
+        }
+
+        [StorableHook(HookType.AfterDeserialization)]
+        private void AfterDeserialization()
+        {
+            RegisterEventHandlers();
+            // compatibility
+            bool changed = false;
+            if (!Operators.OfType<SymbolicRegressionSingleObjectiveTrainingParetoBestSolutionAnalyzer>().Any())
+            {
+                Operators.Add(new SymbolicRegressionSingleObjectiveTrainingParetoBestSolutionAnalyzer());
+                changed = true;
+            }
+            if (!Operators.OfType<SymbolicRegressionSingleObjectiveValidationParetoBestSolutionAnalyzer>().Any())
+            {
+                Operators.Add(new SymbolicRegressionSingleObjectiveValidationParetoBestSolutionAnalyzer());
+                changed = true;
+            }
+            if (changed)
+            {
+                ParameterizeOperators();
+            }
+        }
+
+        private void RegisterEventHandlers()
+        {
+            SymbolicExpressionTreeGrammarParameter.ValueChanged += (o, e) => ConfigureGrammarSymbols();
+        }
+
+        private void ConfigureGrammarSymbols()
+        {
+            var grammar = SymbolicExpressionTreeGrammar as Grammar;
+            if (grammar != null) grammar.ConfigureAsDefaultRegressionGrammar();
+        }
+
+        private void InitializeOperators()
+        {
+            Operators.Add(new SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer());
+            Operators.Add(new SymbolicRegressionSingleObjectiveValidationBestSolutionAnalyzer());
+            Operators.Add(new SymbolicRegressionSingleObjectiveOverfittingAnalyzer());
+            Operators.Add(new SymbolicRegressionSingleObjectiveTrainingParetoBestSolutionAnalyzer());
+            Operators.Add(new SymbolicRegressionSingleObjectiveValidationParetoBestSolutionAnalyzer());
+
+            ParameterizeOperators();
+        }
+
+        private void UpdateEstimationLimits()
+        {
+            if (ProblemData.TrainingIndices.Any())
+            {
+                var targetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).ToList();
+                var mean = targetValues.Average();
+                var range = targetValues.Max() - targetValues.Min();
+                EstimationLimits.Upper = mean + PunishmentFactor * range;
+                EstimationLimits.Lower = mean - PunishmentFactor * range;
+            }
+            else
+            {
+                EstimationLimits.Upper = double.MaxValue;
+                EstimationLimits.Lower = double.MinValue;
+            }
+        }
+
+        protected override void OnProblemDataChanged()
+        {
+            base.OnProblemDataChanged();
+            UpdateEstimationLimits();
+        }
+
+        protected override void ParameterizeOperators()
+        {
+            base.ParameterizeOperators();
+            if (Parameters.ContainsKey(EstimationLimitsParameterName))
+            {
+                var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators);
+                foreach (var op in operators.OfType<ISymbolicDataAnalysisBoundedOperator>())
+                {
+                    op.EstimationLimitsParameter.ActualName = EstimationLimitsParameter.Name;
+                }
+            }
+        }
+    }
+}
