/// <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() { Random r = new Random(); List <IBar> bars = new List <IBar>(); for (int i = 0; i < 1000; i++) { double open = r.NextDouble(); double close = r.NextDouble(); double max = Math.Max(close + r.NextDouble(), open + r.NextDouble()); double min = Math.Min(0, Math.Min(close - r.NextDouble(), open - r.NextDouble())); DateTime dateTime = DateTime.Now; IBar bar = new BaseBar(dateTime, (decimal)open, (decimal)close, (decimal)max, (decimal)min, i); bars.Add(bar); } this.series = new BaseTimeSeries("test", bars); this.openPriceIndicator = new OpenPriceIndicator(this.series); this.minPriceIndicator = new MinPriceIndicator(this.series); this.maxPriceIndicator = new MaxPriceIndicator(this.series); this.volumeIndicator = new VolumeIndicator(this.series); ClosePriceIndicator closePriceIndicator = new ClosePriceIndicator(this.series); this.emaIndicator = new EMAIndicator(closePriceIndicator, 20); }
/// <summary> /// Constructor. /// </summary> /// <param name="series"> the series </param> /// <param name="timeFrame"> the time frame </param> public RandomWalkIndexLowIndicator(TimeSeries series, int timeFrame) : base(series) { _timeFrame = timeFrame; _maxPrice = new MaxPriceIndicator(series); _minPrice = new MinPriceIndicator(series); _averageTrueRange = new AverageTrueRangeIndicator(series, timeFrame); _sqrtTimeFrame = Decimal.ValueOf(timeFrame).Sqrt(); }
public IIIIndicator(ITimeSeries series) : base(series) { _closePriceIndicator = new ClosePriceIndicator(series); _maxPriceIndicator = new MaxPriceIndicator(series); _minPriceIndicator = new MinPriceIndicator(series); _volumeIndicator = new VolumeIndicator(series); }
public WilliamsRIndicator(IIndicator <decimal> indicator, int timeFrame, MaxPriceIndicator MaxPriceIndicator, MinPriceIndicator MinPriceIndicator) : base(indicator) { _indicator = indicator; _timeFrame = timeFrame; _maxPriceIndicator = MaxPriceIndicator; _minPriceIndicator = MinPriceIndicator; }
public StochasticOscillatorKIndicator(IIndicator <decimal> indicator, int timeFrame, MaxPriceIndicator MaxPriceIndicator, MinPriceIndicator MinPriceIndicator) : base(indicator) { _indicator = indicator; _timeFrame = timeFrame; _maxPriceIndicator = MaxPriceIndicator; _minPriceIndicator = MinPriceIndicator; }
/** * Constructor. * * @param series the series * @param timeFrame the time frame */ public RandomWalkIndexHighIndicator(ITimeSeries series, int timeFrame) : base(series) { _timeFrame = timeFrame; _maxPrice = new MaxPriceIndicator(series); _minPrice = new MinPriceIndicator(series); _averageTrueRange = new ATRIndicator(series, timeFrame); _sqrtTimeFrame = ((decimal)timeFrame).Sqrt(); }
/** * Constructor with custom parameters * @param series the time series for this indicator * @param aF acceleration factor * @param MaxA Maximum acceleration * @param increment the increment step */ public ParabolicSarIndicator(ITimeSeries series, decimal aF, decimal MaxA, decimal increment) : base(series) { _series = series; _maxPriceIndicator = new MaxPriceIndicator(series); _minPriceIndicator = new MinPriceIndicator(series); _maxAcceleration = MaxA; _accelerationFactor = aF; _accelerationIncrement = increment; _accelarationStart = aF; }
public void setUp() { timeSeries = new MockTimeSeries(); maxPriceIndicator = new MaxPriceIndicator(timeSeries); }
public void SetUp() { _timeSeries = GenerateTimeSeries.WithArbitraryTicks(); _maxPriceIndicator = new MaxPriceIndicator(_timeSeries); }