Example #1
2
        //  Signal Line: 9-day EMA of MACD
        //  MACD Histogram: MACD - Signal Line
        public static DataSeries[] AllSeries(DataSeries ds, int fastPeriod, int slowPeriod, int signalPeriod, string name)
        {
            DataSeries[] seriesList = new DataSeries[3];

            //MACD
            DataSeries macd = new MACD(ds, fastPeriod, slowPeriod, name);
            seriesList[0] = macd;

            string description;
            //Signal series
            DataSeries signalMacd;
            description = "(" + name + "-signal," + signalPeriod.ToString() + ")";

            //See if it exists in the cache
            if (ds.Cache.ContainsKey(description)) signalMacd = (DataSeries)ds.Cache[description];
            else
            {
                //Create,cache it, return it
                signalMacd = EMA.Series(macd,signalPeriod,name);
                ds.Cache[description] = signalMacd;
            }
            seriesList[1] = signalMacd;

            //Histogram series
            DataSeries histMacd;
            description = "(" + name + "-hist," + signalPeriod.ToString() + ")";
            //See if it exists in the cache
            if (ds.Cache.ContainsKey(description)) histMacd = (DataSeries)ds.Cache[description];
            else
            {
                //Create,cache it, return it
                histMacd = macd - signalMacd;
                ds.Cache[description] = histMacd;
            }
            seriesList[2] = histMacd;
            return seriesList;
        }
Example #2
0
        public static MACD Series(DataSeries ds, int fastPeriod, int slowPeriod, string name)
        {
            //Build description
            string description = "(" + name + "," + fastPeriod.ToString() + "," + slowPeriod.ToString() + ")";

            //See if it exists in the cache
            if (ds.Cache.ContainsKey(description))
            {
                return((MACD)ds.Cache[description]);
            }
            //Create MACD, cache it, return it
            MACD macd = new MACD(ds, fastPeriod, slowPeriod, description);

            ds.Cache[description] = macd;
            return(macd);
        }
Example #3
0
        //  Signal Line: 9-day EMA of MACD
        //  MACD Histogram: MACD - Signal Line
        public static DataSeries[] AllSeries(DataSeries ds, int fastPeriod, int slowPeriod, int signalPeriod, string name)
        {
            DataSeries[] seriesList = new DataSeries[3];

            //MACD
            DataSeries macd = new MACD(ds, fastPeriod, slowPeriod, name);

            seriesList[0] = macd;

            string description;
            //Signal series
            DataSeries signalMacd;

            description = "(" + name + "-signal," + signalPeriod.ToString() + ")";

            //See if it exists in the cache
            if (ds.Cache.ContainsKey(description))
            {
                signalMacd = (DataSeries)ds.Cache[description];
            }
            else
            {
                //Create,cache it, return it
                signalMacd            = EMA.Series(macd, signalPeriod, name);
                ds.Cache[description] = signalMacd;
            }
            seriesList[1] = signalMacd;

            //Histogram series
            DataSeries histMacd;

            description = "(" + name + "-hist," + signalPeriod.ToString() + ")";
            //See if it exists in the cache
            if (ds.Cache.ContainsKey(description))
            {
                histMacd = (DataSeries)ds.Cache[description];
            }
            else
            {
                //Create,cache it, return it
                histMacd = macd - signalMacd;
                ds.Cache[description] = histMacd;
            }
            seriesList[2] = histMacd;
            return(seriesList);
        }
Example #4
0
 public static MACD Series(DataSeries ds, int fastPeriod, int slowPeriod,string name)
 {
     //Build description
     string description = "(" + name + "," + fastPeriod.ToString() + "," + slowPeriod.ToString() + ")";
     //See if it exists in the cache
     if (ds.Cache.ContainsKey(description)) return (MACD)ds.Cache[description];
     //Create MACD, cache it, return it
     MACD macd = new MACD(ds, fastPeriod, slowPeriod, description);
     ds.Cache[description] = macd;
     return macd;
 }