Example #1
0
        public void GetValueWhenTimeFrameIs12()
        {
            ROCIndicator roc = new ROCIndicator(closePrice, 12);

            // Incomplete time frame
            Assert.AreEqual(roc.GetValue(0), 0);
            Assert.AreEqual(roc.GetValue(1), 1.104997885972909670836475700M);
            Assert.AreEqual(roc.GetValue(2), -0.3319067800062832325511282200M);
            Assert.AreEqual(roc.GetValue(3), 0.9647568597236645188392859600M);

            // Complete time frame
            decimal[] results13to20 = new decimal[] {
                -3.8487968152883542004858188200M,
                -4.848880483410522847021487700M,
                -4.5206433873122946493699022900M,
                -6.3438915406709033405279671600M,
                -7.8592301293062817282691957500M,
                -6.2083414610806652852563276800M,
                -4.3130817313541793405523786300M,
                -3.2434109184301613709644012800M
            };
            for (int i = 0; i < results13to20.Length; i++)
            {
                Assert.AreEqual(roc.GetValue(i + 12), results13to20[i]);
            }
        }