예제 #1
0
        public void EmaUsingTimeFrame10UsingClosePrice()
        {
            var ema = new EmaIndicator(new ClosePriceIndicator(_data), 10);

            TaTestsUtils.AssertDecimalEquals(ema.GetValue(9), 63.6536);
            TaTestsUtils.AssertDecimalEquals(ema.GetValue(10), 63.2312);
            TaTestsUtils.AssertDecimalEquals(ema.GetValue(11), 62.9182);
        }
예제 #2
0
        protected override Decimal Calculate(int index)
        {
            var emaEma    = new EmaIndicator(_ema, _timeFrame);
            var emaEmaEma = new EmaIndicator(emaEma, _timeFrame);

            return(Decimal.Three.MultipliedBy(_ema.GetValue(index).Minus(emaEma.GetValue(index))).Plus(emaEmaEma.GetValue(index)));
        }
예제 #3
0
        protected override Decimal Calculate(int index)
        {
            var shortEmaValue = _shortTermEma.GetValue(index);
            var longEmaValue  = _longTermEma.GetValue(index);

            return(shortEmaValue.Minus(longEmaValue).DividedBy(longEmaValue).MultipliedBy(Decimal.Hundred));
        }
예제 #4
0
        public void ValuesLessThanTimeFrameMustBeEqualsToSmaValues()
        {
            var ema = new EmaIndicator(new ClosePriceIndicator(_data), 10);
            var sma = new SmaIndicator(new ClosePriceIndicator(_data), 10);

            for (var i = 0; i < 9; i++)
            {
                Assert.AreEqual(sma.GetValue(i), ema.GetValue(i));
            }
        }
예제 #5
0
        protected override Decimal Calculate(int index)
        {
            var startIndex = Math.Max(0, index - _timeFrame + 1);
            var massIndex  = Decimal.Zero;

            for (var i = startIndex; i <= index; i++)
            {
                var emaRatio = _singleEma.GetValue(i).DividedBy(_doubleEma.GetValue(i));
                massIndex = massIndex.Plus(emaRatio);
            }
            return(massIndex);
        }
예제 #6
0
        public void StackOverflowError()
        {
            IList <Tick> bigListOfTicks = new List <Tick>();

            for (var i = 0; i < 10000; i++)
            {
                bigListOfTicks.Add(GenerateTick.From(i));
            }
            var bigSeries  = GenerateTimeSeries.From(bigListOfTicks);
            var closePrice = new ClosePriceIndicator(bigSeries);
            var ema        = new EmaIndicator(closePrice, 10);

            // If a StackOverflowError is thrown here, then the RecursiveCachedIndicator
            // does not work as intended.
            TaTestsUtils.AssertDecimalEquals(ema.GetValue(9999), 9994.5);
        }
예제 #7
0
        public void EmaFirstValueShouldBeEqualsToFirstDataValue()
        {
            var ema = new EmaIndicator(new ClosePriceIndicator(_data), 1);

            TaTestsUtils.AssertDecimalEquals(ema.GetValue(0), "64.75");
        }
예제 #8
0
 protected override Decimal Calculate(int index)
 {
     return(_emaIndicator.GetValue(index));
 }