コード例 #1
0
        public void GetValue()
        {
            IList <Tick> ticks = new List <Tick>();

            ticks.Add(GenerateTick.From(0, 12, 15, 8));
            ticks.Add(GenerateTick.From(0, 8, 11, 6));
            ticks.Add(GenerateTick.From(0, 15, 17, 14));
            ticks.Add(GenerateTick.From(0, 15, 17, 14));
            ticks.Add(GenerateTick.From(0, 0, 0, 2));
            var atr = new AverageTrueRangeIndicator(GenerateTimeSeries.From(ticks), 3);

            TaTestsUtils.AssertDecimalEquals(atr.GetValue(0), 1);
            TaTestsUtils.AssertDecimalEquals(atr.GetValue(1), 8d / 3);
            TaTestsUtils.AssertDecimalEquals(atr.GetValue(2), 8d / 3 * 2d / 3 + 3);
            TaTestsUtils.AssertDecimalEquals(atr.GetValue(3), (8d / 3 * 2d / 3 + 3) * 2d / 3 + 1);
            TaTestsUtils.AssertDecimalEquals(atr.GetValue(4), ((8d / 3 * 2d / 3 + 3) * 2d / 3 + 1) * 2d / 3 + 15d / 3);
        }
コード例 #2
0
 protected override Decimal Calculate(int index)
 {
     return(_maxPrice.GetValue(Math.Max(0, index - _timeFrame)).Minus(_minPrice.GetValue(index)).DividedBy(_averageTrueRange.GetValue(index).MultipliedBy(_sqrtTimeFrame)));
 }