예제 #1
0
        public Coppock(DataSeries ds, int ROCPeriod1, int ROCPeriod2, int MAPeriod, CoppockCalculation option, string description)
            : base(ds, description)
        {
            base.FirstValidValue = Math.Max(MAPeriod, Math.Max(ROCPeriod1, ROCPeriod2));

            if (FirstValidValue > ds.Count || FirstValidValue < 0)
            {
                FirstValidValue = ds.Count;
            }
            if (ds.Count < Math.Max(ROCPeriod1, ROCPeriod2))
            {
                return;
            }

            DataSeries Coppock  = WMA.Series((ROC.Series(ds, ROCPeriod1) + ROC.Series(ds, ROCPeriod2)), MAPeriod);
            DataSeries Coppock2 = WMA.Series((Community.Indicators.FastSMA.Series(ds, 22) / Community.Indicators.FastSMA.Series(ds >> 250, 22) - 1), 150);

            for (int bar = FirstValidValue; bar < ds.Count; bar++)
            {
                if (option == CoppockCalculation.Option1)
                {
                    base[bar] = Coppock[bar];
                }
                else
                {
                    base[bar] = Coppock2[bar];
                }
            }
        }
예제 #2
0
        public static Coppock Series(DataSeries ds, int ROCPeriod1, int ROCPeriod2, int MAPeriod, CoppockCalculation option)
        {
            string description = string.Concat(new object[] { "Coppock(", ds.Description, ",", ROCPeriod1, ",", ROCPeriod2, ",", MAPeriod, ",", option, ")" });

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

            Coppock _Coppock = new Coppock(ds, ROCPeriod1, ROCPeriod2, MAPeriod, option, description);

            ds.Cache[description] = _Coppock;
            return(_Coppock);
        }