protected override PatternResult <Trend?> ComputeByIndexImpl(int index)
        {
            if (index < 1)
            {
                return(new PatternResult <Trend?>(Equity[index].DateTime, null));
            }

            var latest       = _smaOscillator.ComputeByIndex(index);
            var secondLatest = _smaOscillator.ComputeByIndex(index - 1);

            return(new PatternResult <Trend?>(Equity[index].DateTime, Decision.IsTrending(latest.Osc - secondLatest.Osc)));
        }
예제 #2
0
        public async Task TestSmaOscAsync()
        {
            var equity = await ImportEquityAsync();

            var indicator = new SimpleMovingAverageOscillator(equity, 10, 30);
            var result    = indicator.ComputeByIndex(equity.Count - 1);

            Assert.IsTrue(2.82m.IsApproximatelyEquals(result.Osc.Value));
        }