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

            var currentValue  = _smaIndicator.ComputeByIndex(index).Sma;
            var previousValue = _smaIndicator.ComputeByIndex(index - 1).Sma;

            return(new PatternResult <Trend?>(Equity[index].DateTime, Decision.IsTrending(currentValue - previousValue)));
        }
Beispiel #2
0
        public async Task TestSmaAsync()
        {
            var equity = await ImportEquityAsync();

            var indicator = new SimpleMovingAverage(equity, 30);

            Console.WriteLine($"Sma={equity.Sma(30)[equity.Count - 1].Sma}");
            var result = indicator.ComputeByIndex(equity.Count - 1).Sma;

            Assert.IsTrue(136.23m.IsApproximatelyEquals(result.Value));
        }
        protected override PatternResult <Match?> ComputeByIndexImpl(int index)
        {
            var result = _smaIndicator.ComputeByIndex(index);

            return(new PatternResult <Match?>(Equity[index].DateTime, Decision.IsMatch(Equity[index].Close.IsLargerThan(result.Sma))));
        }