public void ResetsProperly()
        {
            var left      = new Maximum("left", 2);
            var right     = new Minimum("right", 2);
            var composite = new CompositeIndicator(left, right, (l, r) => l.Current + r.Current);

            left.Update(DateTime.Today, 1d);
            right.Update(DateTime.Today, -1d);

            left.Update(DateTime.Today.AddDays(1), -1d);
            right.Update(DateTime.Today.AddDays(1), 1d);

            Assert.AreEqual(left.PeriodsSinceMaximum, 1);
            Assert.AreEqual(right.PeriodsSinceMinimum, 1);

            composite.Reset();
            TestHelper.AssertIndicatorIsInDefaultState(composite);
            TestHelper.AssertIndicatorIsInDefaultState(left);
            TestHelper.AssertIndicatorIsInDefaultState(right);
            Assert.AreEqual(left.PeriodsSinceMaximum, 0);
            Assert.AreEqual(right.PeriodsSinceMinimum, 0);
        }
Example #2
0
        public void ResetsProperly()
        {
            var left      = new Maximum("left", 2);
            var right     = new Minimum("right", 2);
            var composite = new CompositeIndicator <IndicatorDataPoint>(left, right, (l, r) => l + r);

            left.Update(DateTime.Today, TimeZone.Utc, 1m);
            right.Update(DateTime.Today, TimeZone.Utc, -1m);

            left.Update(DateTime.Today.AddDays(1), TimeZone.Utc, -1m);
            right.Update(DateTime.Today.AddDays(1), TimeZone.Utc, 1m);

            Assert.Equal(1, left.PeriodsSinceMaximum);
            Assert.Equal(1, right.PeriodsSinceMinimum);

            composite.Reset();
            TestHelper.AssertIndicatorIsInDefaultState(composite);
            TestHelper.AssertIndicatorIsInDefaultState(left);
            TestHelper.AssertIndicatorIsInDefaultState(right);
            Assert.Equal(0, left.PeriodsSinceMaximum);
            Assert.Equal(0, right.PeriodsSinceMinimum);
        }
Example #3
0
 /// <summary>
 /// Resets this indicator to its initial state
 /// </summary>
 public override void Reset()
 {
     _sharpeRatio.Reset();
     _roc.Reset();
     base.Reset();
 }
Example #4
0
        public void ResetsProperly() {
            var left = new Maximum("left", 2);
            var right = new Minimum("right", 2);
            var composite = new CompositeIndicator<IndicatorDataPoint>(left, right, (l, r) => l + r);

            left.Update(DateTime.Today, 1m);
            right.Update(DateTime.Today,-1m);

            left.Update(DateTime.Today.AddDays(1), -1m);
            right.Update(DateTime.Today.AddDays(1), 1m);

            Assert.AreEqual(left.PeriodsSinceMaximum, 1);
            Assert.AreEqual(right.PeriodsSinceMinimum, 1);

            composite.Reset();
            TestHelper.AssertIndicatorIsInDefaultState(composite);
            TestHelper.AssertIndicatorIsInDefaultState(left);
            TestHelper.AssertIndicatorIsInDefaultState(right);
            Assert.AreEqual(left.PeriodsSinceMaximum, 0);
            Assert.AreEqual(right.PeriodsSinceMinimum, 0);
        }