public void ComparesAgainstExternalData() { var adx = new AverageDirectionalIndex("adx", 14); const double epsilon = .0001; TestHelper.TestIndicator(adx, "spy_with_adx.txt", "ADX 14", (ind, expected) => Assert.AreEqual(expected, (double)((AverageDirectionalIndex)ind).Current.Value, epsilon) ); adx.Reset(); TestHelper.TestIndicator(adx, "spy_with_adx.txt", "+DI14", (ind, expected) => Assert.AreEqual(expected, (double)((AverageDirectionalIndex)ind).PositiveDirectionalIndex.Current.Value, epsilon) ); adx.Reset(); TestHelper.TestIndicator(adx, "spy_with_adx.txt", "-DI14", (ind, expected) => Assert.AreEqual(expected, (double)((AverageDirectionalIndex)ind).NegativeDirectionalIndex.Current.Value, epsilon) ); }
public void ResetsProperly() { var adxIndicator = new AverageDirectionalIndex("ADX", 14); foreach (var data in TestHelper.GetTradeBarStream("spy_with_adx.txt", false)) { adxIndicator.Update(data); } Assert.IsTrue(adxIndicator.IsReady); adxIndicator.Reset(); }
public void ComparesAgainstExternalDataAfterReset() { var adx = new AverageDirectionalIndex("adx", 14); const double epsilon = 1; TestHelper.TestIndicator(adx, "spy_with_adx.txt", "ADX 14", (ind, expected) => ((double)((AverageDirectionalIndex)ind).Current.Price).Should() .BeApproximately(expected, epsilon)); adx.Reset(); TestHelper.TestIndicator(adx, "spy_with_adx.txt", "ADX 14", (ind, expected) => ((double)((AverageDirectionalIndex)ind).Current.Price).Should() .BeApproximately(expected, epsilon)); }
/// <summary> /// Resets this indicator to its initial state /// </summary> public override void Reset() { _adx.Reset(); _adxHistory.Reset(); base.Reset(); }