public StopLossRule(string name,
            TimeIntervalDefinition executeFrequency,
            Variable iterator,
            Statement statement,
            BooleanExpression stopLossCondition,
            Variable positionSet)

            : base(name, executeFrequency,
            // wrap the statement with for all loop
            // and null checking for position
               new ForAllStatement(
                    iterator, positionSet,
                    new IfStatement(new NotEqual(){
                        LeftExpression = new PropertyAccessor(iterator,"Currency"),
                        RightExpression = new Constant(typeof(DBNull),null)},
                        new CompositeStatement(
                            new List<Statement>{
                                    statement,
                                    new IfStatement(stopLossCondition,new PositionStopLoss(iterator))
                                }
                        )            
                    )
                    
                ), stopLossCondition, positionSet
            
            
            )
        {
        }
        public OpenPosition(Variable positionSet, Expression currency)
        {
            if (positionSet.Type != typeof(PositionSet))
                throw new Exception("Only with type PositionSet is accepted");

            _positionSet = positionSet;
            _currency = currency;
        }
 public PropertyAccessor(Variable variable, string propertyName)
 {
     _variable = variable;
     _propertyName = propertyName;
 }
 public TakeProfitReEntryRule(string name, TimeIntervalDefinition executeFrequency, Statement statement, BooleanExpression condition, Variable positionSet)
     : base(name, executeFrequency, statement, condition, positionSet) { }
 public ConditionalRule(string name, TimeIntervalDefinition executeFrequency, Statement statement, BooleanExpression condition, Variable positionSet) :
     base(name, executeFrequency, statement)
 {
     _condition = condition;
     _positionSet = positionSet;
 }
 public PositionStopLossReEntry(Variable position)
 {
     _position = position;
 }
        /// <summary>
        /// Create or retrieve a variable from the variable table
        /// </summary>
        /// <param name="name">name of the variable</param>
        /// <param name="type">type of the variable</param>
        /// <returns></returns>
        private Variable CreateVariable(string name, Type type)
        {
            Variable result;
            if (!_variableDict.TryGetValue(name, out result))
            {
                if (type != null)
                    _variableDict[name] = new Variable(name, type);
                else
                    _variableDict[name] = new Variable(name);
            }

            return _variableDict[name];
        }
 public StopLossReEntryRule(string name, TimeIntervalDefinition executeFrequency, Statement statement
     ,Variable positionSet, BooleanExpression stopLossCondition)
     : base(name, executeFrequency, statement, stopLossCondition, positionSet) {
 }
 public PositionStopLoss(Variable position)
 {
     _position = position;
 }
 public MethodAccessor(Variable variable, string methodName, Expression[] parameters)
 {
     _variable = variable;
     _parameters = parameters;
     _methodName = methodName;
 }
 public Assignment(Variable target, Expression expression)
 {
     _target = target;
     _expression = expression;
 }
 public ForAllStatement(Variable iterator, Expression collection, Statement innerStatement)
 {
     _iterator = iterator;
     _collection = collection;
     _innerStatement = innerStatement;
 }