Ejemplo n.º 1
0
        public void PrimaryOutputIsFastStochProperty()
        {
            var stochastics = new Stochastic("sto", 12, 3, 5);

            TestHelper.TestIndicator(stochastics, "spy_with_stoch12k3.txt", "Stochastics 12 %K 3",
                (ind, expected) => Assert.AreEqual((double) ((Stochastic) ind).FastStoch.Current.Value, ind.Current.Value)
                );
        }
Ejemplo n.º 2
0
        public void ComparesAgainstExternalDataOnStochasticsD()
        {
            var stochastics = new Stochastic("sto", 12, 3, 5);

            const double epsilon = 1e-3;
            TestHelper.TestIndicator(stochastics, "spy_with_stoch12k3.txt", "%D 5",
                (ind, expected) => Assert.AreEqual(expected, (double) ((Stochastic) ind).StochD.Current.Value, epsilon)
                );
        }
Ejemplo n.º 3
0
 public SchaffTrendCycle(string name, int fastPeriod, int slowPeriod, int signalPeriod, decimal factor = 0.5m, MovingAverageType movingAverageType = MovingAverageType.Exponential) : base(name)
 {
     _macd   = new MovingAverageConvergenceDivergence(name + "_MACD", fastPeriod, slowPeriod, signalPeriod, movingAverageType);
     _frac1  = new Stochastic(name + "Frac1", 10, 10, 10);
     _frac2  = new Stochastic(name + "Frac2", 10, 10, 10);
     _pf     = new Identity(name + "_PF");
     _pff    = new Identity(name + "_PFF");
     _factor = factor;
 }
Ejemplo n.º 4
0
 public void HandlesEqualMinAndMax()
 {
     var reference = new DateTime(2015, 09, 01);
     var stochastics = new Stochastic("sto", 2, 2, 2);
     for (int i = 0; i < 4; i++)
     {
         var bar = new TradeBar{Time = reference.AddSeconds(i)};
         bar.Open = bar.Close = bar.High = bar.Low = bar.Volume = 1;
         stochastics.Update(bar);
         Assert.AreEqual(0m, stochastics.Current.Value);
     }
 }
Ejemplo n.º 5
0
        public void ResetsProperly()
        {
            var stochastics = new Stochastic("sto", 12, 3, 5);

            foreach (var bar in TestHelper.GetTradeBarStream("spy_with_stoch12k3.txt", false))
            {
                stochastics.Update(bar);
            }
            Assert.IsTrue(stochastics.IsReady);
            Assert.IsTrue(stochastics.FastStoch.IsReady);
            Assert.IsTrue(stochastics.StochK.IsReady);
            Assert.IsTrue(stochastics.StochD.IsReady);

            stochastics.Reset();

            TestHelper.AssertIndicatorIsInDefaultState(stochastics);
            TestHelper.AssertIndicatorIsInDefaultState(stochastics.FastStoch);
            TestHelper.AssertIndicatorIsInDefaultState(stochastics.StochK);
            TestHelper.AssertIndicatorIsInDefaultState(stochastics.StochD);
        }
Ejemplo n.º 6
0
 public SchaffTrendCycle(string name, int fastPeriod, int slowPeriod, int signalPeriod, MovingAverageType movingAverageType) : base(name)
 {
     _macd  = new MovingAverageConvergenceDivergence(name + "_MACD", fastPeriod, slowPeriod, signalPeriod, movingAverageType);
     _frac1 = new Stochastic(name + "Frac1", 10, 10, 10);
     _frac2 = new Stochastic(name + "Frac2", 10, 10, 10);
 }