Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/Evaluator/EvaluatorTradeRules.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/Evaluator/EvaluatorTradeRules.cs	(revision 9498)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/Evaluator/EvaluatorTradeRules.cs	(revision 9499)
@@ -12,4 +12,5 @@
 using HeuristicLab.Problems.DataAnalysis.Symbolic;
 using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Problems.TradeRules.Evaluator;
 
 namespace HeuristicLab.Problems.TradeRules
@@ -55,4 +56,5 @@
             double tradingCash = OnlineTradeRulesCalculator.Calculate(estimatedValues, problemData, rows);
             
+
             return tradingCash;
         }
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/Evaluator/OnlineHeuristicTradeRulesCalculator.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/Evaluator/OnlineHeuristicTradeRulesCalculator.cs	(revision 9499)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/Evaluator/OnlineHeuristicTradeRulesCalculator.cs	(revision 9499)
@@ -0,0 +1,65 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Problems.DataAnalysis;
+
+namespace HeuristicLab.Problems.TradeRules.Evaluator
+{
+    class OnlineHeuristicTradeRulesCalculator
+    {
+        private static double numberUpDays;
+        private static double numberDownDays;
+
+        public static double Calculate(IEnumerable<double> estimatedValues, IRegressionProblemData problemData, IEnumerable<int> rows)
+        {
+            double value = 0.0;
+            int position = 1;
+            int countUp = 0;
+            int countDown = 0;
+            numberUpDays=0.0;
+            numberDownDays=0.0;
+            
+            int [] row = rows.ToArray();
+            double [] closePrice= problemData.Dataset.GetDoubleValues("\"Close\"").ToArray();
+            double[] estimated = estimatedValues.ToArray();
+
+            while (position < row.Length)
+            {
+                if ((closePrice[row[position]] - closePrice[row[(position - 1)]]) > 0)
+                {
+                    countUp++;
+                    if (estimated[(position - 1)] == 1)
+                    {
+                        numberUpDays++;
+                        value++;
+                    }
+                }
+                else if ((closePrice[row[position]] - closePrice[row[(position - 1)]]) <= 0) 
+                {
+                    countDown++;
+                    if (estimated[(position - 1)] == -1)
+                    {
+                        numberDownDays++;
+                        value++;
+                    }
+                }
+                    position++;
+            }
+            numberUpDays = numberUpDays / countUp;
+            numberDownDays = numberDownDays / countDown;
+            return value/(row.Length-2);
+        }
+
+        public static double getNumberUpDays()
+        {
+            return numberUpDays;
+        }
+
+        public static double getNumberDownDays()
+        {
+            return numberDownDays;
+        }
+
+    }
+}
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/Grammar.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/Grammar.cs	(revision 9498)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/Grammar.cs	(revision 9499)
@@ -112,5 +112,5 @@
         SetSubtreeCount(meanTradeSymbols, 1, 1);
         SetSubtreeCount(macd, 3, 3);
-        SetSubtreeCount(rsi, 1, 1);
+        SetSubtreeCount(rsi, 3, 3);
         SetSubtreeCount(comparisonSymbols, 2, 2);
         SetSubtreeCount(and, 2, 2);
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/HeuristicLab.Problems.TradeRules-1.0.csproj
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/HeuristicLab.Problems.TradeRules-1.0.csproj	(revision 9498)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/HeuristicLab.Problems.TradeRules-1.0.csproj	(revision 9499)
@@ -42,4 +42,5 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Evaluator\OnlineHeuristicTradeRulesCalculator.cs" />
     <Compile Include="Symbols\AverageTrade.cs" />
     <Compile Include="Symbols\BoolConstant.cs" />
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/Interpreter.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/Interpreter.cs	(revision 9498)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/Interpreter.cs	(revision 9499)
@@ -131,5 +131,4 @@
 
             public const byte Variable = 13;
-            public const byte Constant = 14;
             public const byte ConstantInt = 16;
             public const byte BoolConstant = 15;
@@ -156,5 +155,4 @@
       { typeof(Subtraction), OpCodes.Sub },
       { typeof(Multiplication), OpCodes.Mul },
-      { typeof(Constant), OpCodes.Constant },
       { typeof(BoolConstant), OpCodes.BoolConstant },
       { typeof(ConstantInt), OpCodes.ConstantInt },
@@ -306,9 +304,4 @@
                         var variableTreeNode = (VariableTreeNode)currentInstr.dynamicNode;
                         return ((IList<double>)currentInstr.iArg0)[row] * variableTreeNode.Weight;
-                    }
-                case OpCodes.Constant:
-                    {
-                        var constTreeNode = currentInstr.dynamicNode as ConstantTreeNode;
-                        return constTreeNode.Value;
                     }
                 case OpCodes.BoolConstant:
@@ -429,4 +422,6 @@
                         //Taking the number of the days for EMA
                         double numberOfDays = Evaluate(dataset, ref row, state);
+                        double upThreshold = Evaluate(dataset, ref row, state);
+                        double downThreshold = Evaluate(dataset, ref row, state);
 
                         double positiveEMA = 0;
@@ -477,6 +472,6 @@
                                         todayRSI = 100 - (100 / (1 + (positiveEMA / negativeEMA)));
 
-                                        if ((yesterdayRSI < 30) && (todayRSI > 30)) outputRSI = 1.0;
-                                        else if ((yesterdayRSI > 70) && (todayRSI < 70)) outputRSI = -1.0;
+                                        if ((yesterdayRSI < downThreshold) && (todayRSI > downThreshold)) outputRSI = 1.0;
+                                        else if ((yesterdayRSI > upThreshold) && (todayRSI < upThreshold)) outputRSI = -1.0;
                                         yesterdayRSI = todayRSI;
                                     }
@@ -502,6 +497,6 @@
                                 }
                                 todayRSI = 100 - (100 / (1 + (positiveEMA / negativeEMA)));
-                                if ((yesterdayRSI < 30) && (todayRSI > 30)) outputRSI = 1.0;
-                                else if ((yesterdayRSI > 70) && (todayRSI < 70)) outputRSI = -1.0;
+                                if ((yesterdayRSI < downThreshold) && (todayRSI > downThreshold)) outputRSI = 1.0;
+                                else if ((yesterdayRSI > upThreshold) && (todayRSI < upThreshold)) outputRSI = -1.0;
                             }
 
@@ -608,5 +603,4 @@
             if (RSIOutputCache == null) RSIOutputCache = new Dictionary<ISymbolicExpressionTreeNode, double>();
 
-
             var state = new InterpreterState(code, necessaryArgStackSize);
             //Evaluate each row of the datase
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/Solution/TradeRulesSolutionBase.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/Solution/TradeRulesSolutionBase.cs	(revision 9498)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/Solution/TradeRulesSolutionBase.cs	(revision 9499)
@@ -9,4 +9,5 @@
 using HeuristicLab.Optimization;
 using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
+using HeuristicLab.Problems.TradeRules.Evaluator;
 
 namespace HeuristicLab.Problems.TradeRules
@@ -17,4 +18,8 @@
         private const string TrainingCashResultName = "Cash after the operation (training)";
         private const string TestCashResultName = "Cash after the operation (test)";
+        private const string TrainingUpDaysResultName = "Number of days that stock market goes up (training)";
+        private const string TrainingDownDaysResultName = "Number of days that stock market goes down (training)";
+        private const string TrainingHeuristicResultName = "Percentage of right actions after the operation (training)";
+        private const string TestHeuristicResultName = "Percentage of right actions after the operation (test)";
         private const string TrainingMeanSquaredErrorResultName = "Mean squared error (training)";
         private const string TestMeanSquaredErrorResultName = "Mean squared error (test)";
@@ -63,4 +68,28 @@
             private set { ((DoubleValue)this[TestCashResultName].Value).Value = value; }
         }
+
+        public double TrainingHeuristic
+        {
+            get { return ((DoubleValue)this[TrainingHeuristicResultName].Value).Value; }
+            private set { ((DoubleValue)this[TrainingHeuristicResultName].Value).Value = value; }
+        }
+        public double TestHeuristic
+        {
+            get { return ((DoubleValue)this[TestHeuristicResultName].Value).Value; }
+            private set { ((DoubleValue)this[TestHeuristicResultName].Value).Value = value; }
+        }
+
+        public double NumberUpDays
+        {
+            get { return ((DoubleValue)this[TrainingUpDaysResultName].Value).Value; }
+            private set { ((DoubleValue)this[TrainingUpDaysResultName].Value).Value = value; }
+        }
+
+        public double NumberDownDays
+        {
+            get { return ((DoubleValue)this[TrainingDownDaysResultName].Value).Value; }
+            private set { ((DoubleValue)this[TrainingDownDaysResultName].Value).Value = value; }
+        }
+
         public double TradeDays
         {
@@ -78,5 +107,5 @@
             private set { ((DoubleValue)this[TestTotalTradesResultName].Value).Value = value; }
         }
-        public double TrainingMeanSquaredError
+       public double TrainingMeanSquaredError
         {
             get { return ((DoubleValue)this[TrainingMeanSquaredErrorResultName].Value).Value; }
@@ -148,52 +177,15 @@
     protected TradeRulesSolutionBase(IRegressionModel model, IRegressionProblemData problemData)
       : base(model, problemData) {
-      Add(new Result(TrainingCashResultName, "Cash obtained after training period in the stock market", new DoubleValue()));
+      /*Add(new Result(TrainingCashResultName, "Cash obtained after training period in the stock market", new DoubleValue()));*/
       Add(new Result(TestCashResultName, "Cash obtained after test period in the stock market", new DoubleValue()));
+      Add(new Result(TrainingHeuristicResultName, "Percentage of right actions after training period in the stock market", new DoubleValue()));
+      Add(new Result(TestHeuristicResultName, "Percentage of right actions after test period in the stock market", new DoubleValue()));
+      Add(new Result(TrainingUpDaysResultName, "Number of days actions go up in the stock market", new DoubleValue()));
+      Add(new Result(TrainingDownDaysResultName, "Number of days actions down up in the stock market", new DoubleValue()));
+     
       Add(new Result(TestTradeDaysResultName, "Number of trading days", new DoubleValue()));
       Add(new Result(TestNumberTradesResultName, "Number of trades", new DoubleValue()));
       Add(new Result(TestTotalTradesResultName, "Total trades", new DoubleValue()));
      }
-
-    [StorableHook(HookType.AfterDeserialization)]
-    private void AfterDeserialization()
-    {
-        // BackwardsCompatibility3.4
-
-        #region Backwards compatible code, remove with 3.5
-
-        if (!ContainsKey(TrainingMeanAbsoluteErrorResultName))
-        {
-            OnlineCalculatorError errorState;
-            Add(new Result(TrainingMeanAbsoluteErrorResultName, "Mean of absolute errors of the model on the training partition", new DoubleValue()));
-            double trainingMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(EstimatedTrainingValues, ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices), out errorState);
-            TrainingMeanAbsoluteError = errorState == OnlineCalculatorError.None ? trainingMAE : double.NaN;
-        }
-
-        if (!ContainsKey(TestMeanAbsoluteErrorResultName))
-        {
-            OnlineCalculatorError errorState;
-            Add(new Result(TestMeanAbsoluteErrorResultName, "Mean of absolute errors of the model on the test partition", new DoubleValue()));
-            double testMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(EstimatedTestValues, ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices), out errorState);
-            TestMeanAbsoluteError = errorState == OnlineCalculatorError.None ? testMAE : double.NaN;
-        }
-
-        if (!ContainsKey(TrainingMeanErrorResultName))
-        {
-            OnlineCalculatorError errorState;
-            Add(new Result(TrainingMeanErrorResultName, "Mean of errors of the model on the training partition", new DoubleValue()));
-            double trainingME = OnlineMeanErrorCalculator.Calculate(EstimatedTrainingValues, ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices), out errorState);
-            TrainingMeanError = errorState == OnlineCalculatorError.None ? trainingME : double.NaN;
-        }
-        if (!ContainsKey(TestMeanErrorResultName))
-        {
-            OnlineCalculatorError errorState;
-            Add(new Result(TestMeanErrorResultName, "Mean of errors of the model on the test partition", new DoubleValue()));
-            double testME = OnlineMeanErrorCalculator.Calculate(EstimatedTestValues, ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices), out errorState);
-            TestMeanError = errorState == OnlineCalculatorError.None ? testME : double.NaN;
-        }
-        #endregion
-    }
-
-
     protected void CalculateResults()
     {
@@ -203,7 +195,18 @@
         IEnumerable<double> estimatedTestValues = EstimatedTestValues; // cache values
         IEnumerable<double> originalTestValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices);
-
-        double trainingCTR = OnlineTradeRulesCalculator.Calculate(estimatedTrainingValues, ProblemData, ProblemData.TrainingIndices);
-        TrainingCash = trainingCTR;
+   
+        /*double trainingCTR = OnlineTradeRulesCalculator.Calculate(estimatedTrainingValues, ProblemData, ProblemData.TrainingIndices);
+        TrainingCash = trainingCTR;*/
+
+        double trainingHTR = OnlineHeuristicTradeRulesCalculator.Calculate(estimatedTrainingValues, ProblemData, ProblemData.TrainingIndices);
+        TrainingHeuristic = trainingHTR;
+        double trainingUpDays = OnlineHeuristicTradeRulesCalculator.getNumberUpDays();
+        NumberUpDays = trainingUpDays;
+        double trainingDownDays = OnlineHeuristicTradeRulesCalculator.getNumberDownDays();
+        NumberDownDays = trainingDownDays;
+
+        double testHTR = OnlineHeuristicTradeRulesCalculator.Calculate(estimatedTestValues, ProblemData, ProblemData.TestIndices);
+        TestHeuristic = testHTR;
+
         double testCTR = OnlineTradeRulesCalculator.Calculate(estimatedTestValues, ProblemData, ProblemData.TestIndices);
         TestCash = testCTR;
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/Symbols/ConstantIntTreeNode.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/Symbols/ConstantIntTreeNode.cs	(revision 9498)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/Symbols/ConstantIntTreeNode.cs	(revision 9499)
@@ -51,5 +51,5 @@
             base.ResetLocalParameters(random);
             
-            Value = random.Next(25)+1;
+            Value = random.Next(100)+1;
         }
 
Index: /branches/sluengo/HeuristicLab.Problems.TradeRules/Symbols/RSI.cs
===================================================================
--- /branches/sluengo/HeuristicLab.Problems.TradeRules/Symbols/RSI.cs	(revision 9498)
+++ /branches/sluengo/HeuristicLab.Problems.TradeRules/Symbols/RSI.cs	(revision 9499)
@@ -11,6 +11,6 @@
     class RSI: Symbol
     {
-        private const int minimumArity = 1;
-        private const int maximumArity = 1;
+        private const int minimumArity = 3;
+        private const int maximumArity = 3;
 
         public override int MinimumArity
