Beispiel #1
0
        public KELTNER(DataBars ds, double EmaPeriod, double AtrMult, double AtrPeriod, string name)
            : base(ds, name)
        {
            this.Name = name;
            int begin = 0;

            DataSeries ema = EMA.Series(ds.Close, EmaPeriod, "ema");
            DataSeries atr = ATR.Series(ds, AtrPeriod, "atr");

            //DataSeries upperSeries = new DataSeries(ds, name + "-upper");
            DataSeries upperSeries = ema + AtrMult * atr;

            upperSeries.Name = name + "-upper";

            // DataSeries lowerSeries = new DataSeries(ds, name + "-lower");
            DataSeries lowerSeries = ema - AtrMult * atr;

            lowerSeries.Name = name + "-lower";
            FirstValidValue  = Math.Max(ema.FirstValidValue, upperSeries.FirstValidValue);
            this.Name        = name;

            upperSeries.FirstValidValue = FirstValidValue;
            lowerSeries.FirstValidValue = FirstValidValue;
            for (int i = begin, j = 0; j < ema.Count; i++, j++)
            {
                this[i] = ema[j];
            }
            //Cache series
            this.Cache.Add(upperSeries.Name, upperSeries);
            this.Cache.Add(lowerSeries.Name, lowerSeries);
        }
Beispiel #2
0
        /// <summary>
        /// Static method to create ATR DataSeries
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="period"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static ATR Series(DataBars ds, double period, string name)
        {
            //Build description
            string description = "(" + name + "," + period.ToString() + ")";
            //See if it exists in the cache
            object obj = ds.Cache.Find(description);
            if (obj != null) return (ATR)obj;

            //Create indicator, cache it, return it
            ATR indicator = new ATR(ds, period, description);
            ds.Cache.Add(description, indicator);
            return indicator; 
        }
Beispiel #3
0
        /// <summary>
        /// Static method to create ATR DataSeries
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="period"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static ATR Series(DataBars ds, double period, string name)
        {
            //Build description
            string description = "(" + name + "," + period.ToString() + ")";
            //See if it exists in the cache
            object obj = ds.Cache.Find(description);

            if (obj != null)
            {
                return((ATR)obj);
            }

            //Create indicator, cache it, return it
            ATR indicator = new ATR(ds, period, description);

            ds.Cache.Add(description, indicator);
            return(indicator);
        }