Example #1
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)));
        }
Example #2
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);
        }
Example #3
0
 public PpoIndicator(IIndicator <Decimal> indicator, int shortTimeFrame, int longTimeFrame) : base(indicator)
 {
     if (shortTimeFrame > longTimeFrame)
     {
         throw new ArgumentException("Long term period count must be greater than short term period count");
     }
     _shortTermEma = new EmaIndicator(indicator, shortTimeFrame);
     _longTermEma  = new EmaIndicator(indicator, longTimeFrame);
 }
Example #4
0
        /// <summary>
        /// Constructor. </summary>
        /// <param name="series"> the time series </param>
        /// <param name="emaTimeFrame"> the time frame for EMAs (usually 9) </param>
        /// <param name="timeFrame"> the time frame </param>
        public MassIndexIndicator(TimeSeries series, int emaTimeFrame, int timeFrame) : base(series)
        {
            IIndicator <Decimal> highLowDifferential = new DifferenceIndicator(new MaxPriceIndicator(series), new MinPriceIndicator(series)
                                                                               );

            _singleEma = new EmaIndicator(highLowDifferential, emaTimeFrame);
            _doubleEma = new EmaIndicator(_singleEma, emaTimeFrame);             // Not the same formula as DoubleEMAIndicator
            _timeFrame = timeFrame;
        }
Example #5
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));
            }
        }
Example #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);
        }
Example #7
0
 public TripleEmaIndicator(IIndicator <Decimal> indicator, int timeFrame) : base(indicator)
 {
     _timeFrame = timeFrame;
     _ema       = new EmaIndicator(indicator, timeFrame);
 }
Example #8
0
        public void EmaFirstValueShouldBeEqualsToFirstDataValue()
        {
            var ema = new EmaIndicator(new ClosePriceIndicator(_data), 1);

            TaTestsUtils.AssertDecimalEquals(ema.GetValue(0), "64.75");
        }
Example #9
0
 public KeltnerChannelMiddleIndicator(IIndicator <Decimal> indicator, int timeFrameEma) : base(indicator)
 {
     _emaIndicator = new EmaIndicator(indicator, timeFrameEma);
 }