Beispiel #1
0
        /// <summary>
        /// The TRIX (Triple Exponential Average) displays the percentage Rate of Change (ROC) of a triple EMA. Trix oscillates above and below the zero value. The indicator applies triple smoothing in an attempt to eliminate insignificant price movements within the trend that you're trying to isolate.
        /// </summary>
        /// <returns></returns>
        public TRIX TRIX(Data.IDataSeries input, int period, int signalPeriod)
        {
            if (cacheTRIX != null)
            {
                for (int idx = 0; idx < cacheTRIX.Length; idx++)
                {
                    if (cacheTRIX[idx].Period == period && cacheTRIX[idx].SignalPeriod == signalPeriod && cacheTRIX[idx].EqualsInput(input))
                    {
                        return(cacheTRIX[idx]);
                    }
                }
            }

            lock (checkTRIX)
            {
                checkTRIX.Period       = period;
                period                 = checkTRIX.Period;
                checkTRIX.SignalPeriod = signalPeriod;
                signalPeriod           = checkTRIX.SignalPeriod;

                if (cacheTRIX != null)
                {
                    for (int idx = 0; idx < cacheTRIX.Length; idx++)
                    {
                        if (cacheTRIX[idx].Period == period && cacheTRIX[idx].SignalPeriod == signalPeriod && cacheTRIX[idx].EqualsInput(input))
                        {
                            return(cacheTRIX[idx]);
                        }
                    }
                }

                TRIX indicator = new TRIX();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input        = input;
                indicator.Period       = period;
                indicator.SignalPeriod = signalPeriod;
                Indicators.Add(indicator);
                indicator.SetUp();

                TRIX[] tmp = new TRIX[cacheTRIX == null ? 1 : cacheTRIX.Length + 1];
                if (cacheTRIX != null)
                {
                    cacheTRIX.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheTRIX           = tmp;
                return(indicator);
            }
        }
Beispiel #2
0
        /// <summary>
        /// The TRIX (Triple Exponential Average) displays the percentage Rate of Change (ROC) of a triple EMA. Trix oscillates above and below the zero value. The indicator applies triple smoothing in an attempt to eliminate insignificant price movements within the trend that you're trying to isolate.
        /// </summary>
        /// <returns></returns>
        public TRIX TRIX(Data.IDataSeries input, int period, int signalPeriod)
        {
            if (cacheTRIX != null)
                for (int idx = 0; idx < cacheTRIX.Length; idx++)
                    if (cacheTRIX[idx].Period == period && cacheTRIX[idx].SignalPeriod == signalPeriod && cacheTRIX[idx].EqualsInput(input))
                        return cacheTRIX[idx];

            lock (checkTRIX)
            {
                checkTRIX.Period = period;
                period = checkTRIX.Period;
                checkTRIX.SignalPeriod = signalPeriod;
                signalPeriod = checkTRIX.SignalPeriod;

                if (cacheTRIX != null)
                    for (int idx = 0; idx < cacheTRIX.Length; idx++)
                        if (cacheTRIX[idx].Period == period && cacheTRIX[idx].SignalPeriod == signalPeriod && cacheTRIX[idx].EqualsInput(input))
                            return cacheTRIX[idx];

                TRIX indicator = new TRIX();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Period = period;
                indicator.SignalPeriod = signalPeriod;
                Indicators.Add(indicator);
                indicator.SetUp();

                TRIX[] tmp = new TRIX[cacheTRIX == null ? 1 : cacheTRIX.Length + 1];
                if (cacheTRIX != null)
                    cacheTRIX.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheTRIX = tmp;
                return indicator;
            }
        }