/// <summary> /// Resets this indicator to its initial state /// </summary> public override void Reset() { base.Reset(); _shortRoc.Reset(); _longRoc.Reset(); _lwma.Reset(); }
public void ResetsProperly() { const int period = 4; decimal[] values = { 1m, 2m, 3m, 4m, 5m }; var lwma = new LinearWeightedMovingAverage(period); for (int i = 0; i < values.Length; i++) { lwma.Update(new IndicatorDataPoint(DateTime.UtcNow.AddSeconds(i), TimeZone.Utc, values[i])); } Assert.True(lwma.IsReady); Assert.NotEqual(0m, lwma.Current.Price); Assert.NotEqual(0, lwma.Samples); lwma.Reset(); TestHelper.AssertIndicatorIsInDefaultState(lwma); }
// See http://en.wikipedia.org/wiki/Moving_average // for the formula and the numbers in this test. public void ResetsProperly(int period) { var values = new[] { 77m, 79m, 79m, 81m, 83m }; var weights = Enumerable.Range(1, period).ToArray(); var current = weights.Sum(i => i * values[i - 1]) / weights.Sum(); var lwma = new LinearWeightedMovingAverage(period); var time = DateTime.UtcNow; for (var i = 0; i < period; i++) { lwma.Update(time.AddSeconds(i), values[i]); } Assert.AreEqual(current, lwma.Current.Value); Assert.IsTrue(lwma.IsReady); Assert.AreNotEqual(0m, lwma.Current.Value); Assert.AreNotEqual(0, lwma.Samples); lwma.Reset(); TestHelper.AssertIndicatorIsInDefaultState(lwma); }
public void ResetsProperly() { const int period = 4; decimal[] values = { 1m, 2m, 3m, 4m, 5m }; var lwma = new LinearWeightedMovingAverage(period); for (int i = 0; i < values.Length; i++) { lwma.Update(new IndicatorDataPoint(DateTime.UtcNow.AddSeconds(i), values[i])); } Assert.IsTrue(lwma.IsReady); Assert.AreNotEqual(0m, lwma.Current.Value); Assert.AreNotEqual(0, lwma.Samples); lwma.Reset(); TestHelper.AssertIndicatorIsInDefaultState(lwma); }