예제 #1
0
        /// <param name="series"> a time series </param>
        /// <returns> a global extrema strategy </returns>
        public static Strategy BuildStrategy(TimeSeries series)
        {
            if (series == null)
            {
                throw new ArgumentException("Series cannot be null");
            }

            var closePrices = new ClosePriceIndicator(series);

            // Getting the max price over the past week
            var maxPrices    = new MaxPriceIndicator(series);
            var weekMaxPrice = new HighestValueIndicator(maxPrices, NB_TICKS_PER_WEEK);
            // Getting the min price over the past week
            var minPrices    = new MinPriceIndicator(series);
            var weekMinPrice = new LowestValueIndicator(minPrices, NB_TICKS_PER_WEEK);

            // Going long if the close price goes below the min price
            var downWeek   = new MultiplierIndicator(weekMinPrice, Decimal.ValueOf("1.004"));
            var buyingRule = new UnderIndicatorRule(closePrices, downWeek);

            // Going short if the close price goes above the max price
            var upWeek      = new MultiplierIndicator(weekMaxPrice, Decimal.ValueOf("0.996"));
            var sellingRule = new OverIndicatorRule(closePrices, upWeek);

            return(new Strategy(buyingRule, sellingRule));
        }
예제 #2
0
        public void setUp()
        {
            IIndicator <decimal> indicator = new FixeddecimalIndicator(20, 15, 10, 5, 0, -5, -10, 100);

            rule = new OverIndicatorRule(indicator, 5);
        }
예제 #3
0
 public virtual void SetUp()
 {
     _indicator = new FixedDecimalIndicator(20, 15, 10, 5, 0, -5, -10, 100);
     _rule      = new OverIndicatorRule(_indicator, Decimal.ValueOf(5));
 }