/// <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() { ConstantIndicator <decimal> constantIndicator = new ConstantIndicator <decimal>(6); multiplierIndicator = new MultiplierIndicator(constantIndicator, 0.75M); }
public void SetUp() { _constantIndicator = new ConstantIndicator <Decimal>(Decimal.ValueOf(6)); _multiplierIndicator = new MultiplierIndicator(_constantIndicator, Decimal.ValueOf("0.75")); }