Пример #1
0
        public static GreaterThan Series(DataSeries ds, DataSeries comp, double greaterThanWeight, double lessThanWeight)
        {
            string description = string.Concat(new object[] { "GreaterThan(", ds.Description, ",", comp.Description, ",",
                                                              greaterThanWeight, ",", lessThanWeight, ",", ")" });

            if (ds.Cache.ContainsKey(description))
            {
                return((GreaterThan)ds.Cache[description]);
            }

            GreaterThan _GreaterThan = new GreaterThan(ds, comp, greaterThanWeight, lessThanWeight, description);

            ds.Cache[description] = _GreaterThan;
            return(_GreaterThan);
        }
Пример #2
0
        public DVI(DataSeries B, string description)
            : base(B, description)
        {
            base.FirstValidValue = 252;

            DataSeries C = B / Community.Indicators.FastSMA.Series(B, 3) - 1;
            DataSeries D = (Community.Indicators.FastSMA.Series(C, 5) + (Community.Indicators.FastSMA.Series(C, 100) / 10)) / 2;
            DataSeries E = Community.Indicators.FastSMA.Series(D, 5);
            DataSeries F = GreaterThan.Series(B, (B >> 1), 1, -1);
            DataSeries G = (Sum.Series(F, 10) + (Sum.Series(F, 100) / 10)) / 2;
            DataSeries H = Community.Indicators.FastSMA.Series(G, 2);
            // DVI [Magnitude]
            DataSeries I = PercentRank.Series(E, 252);
            // DVI [Stretch]
            DataSeries J   = PercentRank.Series(H, 252);
            DataSeries DVI = (0.8 * I) + (0.2 * J);

            for (int bar = base.FirstValidValue; bar < B.Count; bar++)
            {
                base[bar] = DVI[bar];
            }
        }