Пример #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));
 }