/// <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));
        }
        public void setUp()
        {
            IIndicator <decimal> indicator = new FixeddecimalIndicator(0, 5, 8, 5, 1, 10, 20, 30);

            rule = new UnderIndicatorRule(indicator, 5);
        }
Beispiel #3
0
 public virtual void SetUp()
 {
     _indicator = new FixedDecimalIndicator(0, 5, 8, 5, 1, 10, 20, 30);
     _rule      = new UnderIndicatorRule(_indicator, Decimal.ValueOf(5));
 }