示例#1
0
        public Rex(Bars bars, int period, ChoiceOfMA option, string description)
            : base(bars, description)
        {
            base.FirstValidValue = period;
            DataSeries TVB = (bars.Close - bars.Low) + (bars.Close - bars.Open) - (bars.High - bars.Close);
            //DataSeries TVB = 3 * bars.Close - (bars.Low + bars.Open + bars.High);

            var rangePartitioner = Partitioner.Create(FirstValidValue, bars.Count);

            Parallel.ForEach(rangePartitioner, (range, loopState) =>
            {
                for (int bar = range.Item1; bar < range.Item2; bar++)
                {
                    if (option == ChoiceOfMA.EMA)
                    {
                        base[bar] = EMA.Series(TVB, period, EMACalculation.Modern)[bar];
                    }
                    else
                    if (option == ChoiceOfMA.SMA)
                    {
                        base[bar] = Community.Indicators.FastSMA.Series(TVB, period)[bar];
                    }
                    else
                    if (option == ChoiceOfMA.WMA)
                    {
                        base[bar] = WMA.Series(TVB, period)[bar];
                    }
                    else
                    if (option == ChoiceOfMA.SMMA)
                    {
                        base[bar] = SMMA.Series(TVB, period)[bar];
                    }
                }
            });
        }
示例#2
0
        public static SMMA Series(DataSeries ds, int period)
        {
            string description = string.Concat(new object[] { "SMMA(", ds.Description, ", ", period, ")" });

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

            SMMA _SMMA = new SMMA(ds, period, description);

            ds.Cache[description] = _SMMA;
            return(_SMMA);
        }
示例#3
0
        public EnvelopeLower(DataSeries ds, int period, double pct, ChoiceOfMA ma, string description)
            : base(ds, description)
        {
            if (ma == ChoiceOfMA.SMA)
            {
                base.FirstValidValue = period;
            }
            else
            {
                base.FirstValidValue = (period * 3);
            }

            if (FirstValidValue > ds.Count || FirstValidValue < 0)
            {
                FirstValidValue = ds.Count;
            }
            if (ds.Count < period)
            {
                return;
            }

            var rangePartitioner = Partitioner.Create(0, ds.Count);

            Parallel.ForEach(rangePartitioner, (range, loopState) =>
            {
                for (int bar = range.Item1; bar < range.Item2; bar++)
                {
                    if (ma == ChoiceOfMA.EMA)
                    {
                        base[bar] = EMA.Series(ds, period, EMACalculation.Modern)[bar] * (1 - (pct / 100));
                    }
                    else
                    if (ma == ChoiceOfMA.SMA)
                    {
                        base[bar] = Community.Indicators.FastSMA.Series(ds, period)[bar] * (1 - (pct / 100));
                    }
                    else
                    if (ma == ChoiceOfMA.WMA)
                    {
                        base[bar] = WMA.Series(ds, period)[bar] * (1 - (pct / 100));
                    }
                    else
                    if (ma == ChoiceOfMA.SMMA)
                    {
                        base[bar] = SMMA.Series(ds, period)[bar] * (1 - (pct / 100));
                    }
                }
            });
        }
示例#4
0
        public ShiftedMA(DataSeries ds, int period, int shift, ChoiceOfMA option, string description)
            : base(ds, description)
        {
            if (ds.Count < period + shift)
            {
                return;
            }

            if (option == ChoiceOfMA.SMA)
            {
                base.FirstValidValue = period + shift;
            }
            else
            {
                base.FirstValidValue = (period * 3) + shift;
            }

            for (int bar = FirstValidValue; bar < ds.Count; bar++)
            {
                if (option == ChoiceOfMA.EMA)
                {
                    base[bar] = EMA.Series(ds, period, EMACalculation.Modern)[bar - shift];
                }
                else
                if (option == ChoiceOfMA.SMA)
                {
                    base[bar] = Community.Indicators.FastSMA.Series(ds, period)[bar - shift];
                }
                else
                if (option == ChoiceOfMA.WMA)
                {
                    base[bar] = WMA.Series(ds, period)[bar - shift];
                }
                else
                if (option == ChoiceOfMA.SMMA)
                {
                    base[bar] = SMMA.Series(ds, period)[bar - shift];
                }
            }
        }