예제 #1
0
        /// <summary>
        /// Creates a copy of this trade system with new trade conditions.
        /// </summary>
        /// <param name="buyCondition">The buy condition.</param>
        /// <param name="sellCondition">The sell condition.</param>
        /// <returns>A copy of this trade system with new trade conditions.</returns>
        public TradeSystem CloneWithNewRules(TradeCondition buyCondition, TradeCondition sellCondition)
        {
            TradeSystem clone = this.Clone();

            clone.BuyCondition = buyCondition;
            return(clone);
        }
예제 #2
0
        /// <summary>
        /// Deep clone the object by creating new objects all the way down.
        /// </summary>
        /// <returns>A new object with a different reference and same data.</returns>
        internal TradeCondition Clone()
        {
            TradeCondition tc = new TradeCondition();

            for (int i = 0; i < this.TradeRules.Count; i++)
            {
                TradeCondition temp = new TradeCondition();
                temp.TradeRules.Add(this.TradeRules[0]);
                temp.TradeRules.ElementAt(0).IndicatorName1 = this.TradeRules.ElementAt(i).IndicatorName1;
                temp.TradeRules.ElementAt(0).IndicatorName2 = this.TradeRules.ElementAt(i).IndicatorName2;
                temp.TradeRules.ElementAt(0).CompareType    = this.TradeRules.ElementAt(i).CompareType;

                tc.TradeRules.Add(temp.TradeRules[0]);
            }
            for (int i = 0; i < this.RuleJoinTypes.Count; i++)
            {
                tc.RuleJoinTypes.Add(DeepCopy.getDeepCopy(this.RuleJoinTypes.ElementAt(i)));
            }
            //tc.RuleJoinTypes = this.RuleJoinTypes;
            //tc.TradeRules = this.TradeRules;
            return(tc);
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the TradeSystem class.
 /// </summary>
 /// <param name="buyCondition">Buy conditions for the trade system</param>
 /// <param name="sellCondition">Sell conditions for the trade system</param>
 /// <param name="startDate">Date to start trading</param>
 /// <param name="endDate">Date to stop trading</param>
 /// <param name="financialSettings">Financial settings for the trade system</param>
 /// <param name="shorts">Short trades are allowed.</param>
 /// <param name="longs">Long trades are allowed.</param>
 public TradeSystem(
     TradeCondition buyCondition
     )
 {
     this.BuyCondition = buyCondition;
 }