Exemple #1
0
        public static GMA Series(DataSeries ds, int period)
        {
            string description = string.Concat(new object[] { "GMA(", ds.Description, ",", period, ")" });

            if (ds.Cache.ContainsKey(description))
            {
                return((GMA)ds.Cache[description]);
            }
            GMA _gma = new GMA(ds, period, description);

            ds.Cache[description] = _gma;
            return(_gma);
        }
Exemple #2
0
        /*
         *              The creation of the oscillator involves taking the arithmetic average of the percentage returns (or 1-day ROCs) over the last 5 days.
         *              A geometric average is created by simply adding 1 to the percentage returns and taking the product of this series over the last 5 days
         *              (the cumulative return).
         *              The geometric average is derived by subtracting 1 from the cumulative return.
         *              Then we subtract the arithmetic return from the geometric return to find the divergence.
         *              This divergence is smoothed twice using a 3-day average to create smooth signals (note that the raw divergence produces signals in the same direction).
         *              Finally this smoothed divergence is “bounded,” by taking the PERCENTRANK of the series going back 1-year.
         */

        public GAMDO(Bars bars, string description)
            : base(bars, description)
        {
            base.FirstValidValue = 252;
            int period = 5;

            DataSeries ArAvg         = Community.Indicators.FastSMA.Series(bars.Close / (bars.Close >> 1), period) - 1d;
            DataSeries GeomAvg       = GMA.Series(bars.Close / (bars.Close >> 1), period) - 1d;
            DataSeries Diver         = GeomAvg - ArAvg;
            DataSeries SmoothedDiver = Community.Indicators.FastSMA.Series(Diver, 3);

            for (int bar = FirstValidValue; bar < bars.Count; bar++)
            {
                base[bar] = PercentRank.Series(SmoothedDiver, 252)[bar];
            }
        }