Esempio n. 1
0
        /// <summary>
        /// Jurik JMA Adaptive Moving Average is a Moving Average Indicator that shows the average value of a security's price over a period of time.
        /// </summary>
        /// <returns></returns>
        public JurikJMA JurikJMA(Data.IDataSeries input, double phase, double smoothing)
        {
            checkJurikJMA.Phase = phase;
            phase = checkJurikJMA.Phase;
            checkJurikJMA.Smoothing = smoothing;
            smoothing = checkJurikJMA.Smoothing;

            if (cacheJurikJMA != null)
            {
                for (int idx = 0; idx < cacheJurikJMA.Length; idx++)
                {
                    if (Math.Abs(cacheJurikJMA[idx].Phase - phase) <= double.Epsilon && Math.Abs(cacheJurikJMA[idx].Smoothing - smoothing) <= double.Epsilon && cacheJurikJMA[idx].EqualsInput(input))
                    {
                        return(cacheJurikJMA[idx]);
                    }
                }
            }

            JurikJMA indicator = new JurikJMA();

            indicator.SetUp();
            indicator.CalculateOnBarClose = CalculateOnBarClose;
            indicator.Input     = input;
            indicator.Phase     = phase;
            indicator.Smoothing = smoothing;

            JurikJMA[] tmp = new JurikJMA[cacheJurikJMA == null ? 1 : cacheJurikJMA.Length + 1];
            if (cacheJurikJMA != null)
            {
                cacheJurikJMA.CopyTo(tmp, 0);
            }
            tmp[tmp.Length - 1] = indicator;
            cacheJurikJMA       = tmp;
            Indicators.Add(indicator);

            return(indicator);
        }
Esempio n. 2
0
        /// <summary>
        /// Jurik JMA Adaptive Moving Average is a Moving Average Indicator that shows the average value of a security's price over a period of time.
        /// </summary>
        /// <returns></returns>
        public JurikJMA JurikJMA(Data.IDataSeries input, double phase, double smoothing)
        {
            checkJurikJMA.Phase = phase;
            phase = checkJurikJMA.Phase;
            checkJurikJMA.Smoothing = smoothing;
            smoothing = checkJurikJMA.Smoothing;

            if (cacheJurikJMA != null)
                for (int idx = 0; idx < cacheJurikJMA.Length; idx++)
                    if (Math.Abs(cacheJurikJMA[idx].Phase - phase) <= double.Epsilon && Math.Abs(cacheJurikJMA[idx].Smoothing - smoothing) <= double.Epsilon && cacheJurikJMA[idx].EqualsInput(input))
                        return cacheJurikJMA[idx];

            JurikJMA indicator = new JurikJMA();
            indicator.SetUp();
            indicator.CalculateOnBarClose = CalculateOnBarClose;
            indicator.Input = input;
            indicator.Phase = phase;
            indicator.Smoothing = smoothing;

            JurikJMA[] tmp = new JurikJMA[cacheJurikJMA == null ? 1 : cacheJurikJMA.Length + 1];
            if (cacheJurikJMA != null)
                cacheJurikJMA.CopyTo(tmp, 0);
            tmp[tmp.Length - 1] = indicator;
            cacheJurikJMA = tmp;
            Indicators.Add(indicator);

            return indicator;
        }