/// <summary> /// Initializes a new instance of the <see cref="PositionBackTester"/> class. /// </summary> /// <param name="ticker">The ticker.</param> /// <param name="priceHistory">The price history.</param> /// <param name="broker">The broker.</param> /// <param name="adxCalculator">The ADX calculator.</param> /// <param name="obvCalculator">The OBV calculator.</param> /// <param name="emaCalculator">The EMA calculator.</param> public PositionBackTester(string ticker, List<PriceData> priceHistory, Broker broker, AverageDirectionalMovementCalculator adxCalculator, OnBalanceVolumeCalculator obvCalculator, MovingAverageCalculator emaCalculator) { this.priceHistory = priceHistory; this.broker = broker; this.ticker = ticker; this.shortTermHighs = new List<float>(); this.shortTermLows = new List<float>(); this.intermediateHighs = new List<float>(); this.intermediateLows = new List<float>(); this.longTermHighs = new List<float>(); this.longTermLows = new List<float>(); // Perform technical analysis calculations in advance of the simulation. adxCalculator.PopulateHistoricalAdxValues(this.priceHistory); obvCalculator.PopulateHistoricalObvValues(this.priceHistory); emaCalculator.PopulateHistoricalEmaValues(this.priceHistory); }
/// <summary> /// Runs the swing back test. /// </summary> /// <param name="history">The price history.</param> /// <returns> /// The results of the back test. /// </returns> private static BackTestResults RunSwingTest(List<PriceData> history) { var broker = new Broker(InitialAccountSize); var backTester = new SwingBackTester( history, broker, new AverageDirectionalMovementCalculator(), new OnBalanceVolumeCalculator(), new MovingAverageCalculator()); return backTester.RunBackTest(); }