Exemple #1
0
        /// <summary>
        /// The TSI (True Strength Index) is a momentum-based indicator, developed by William Blau. Designed to determine both trend and overbought/oversold conditions, the TSI is applicable to intraday time frames as well as long term trading.
        /// </summary>
        /// <returns></returns>
        public TSI TSI(Data.IDataSeries input, int fast, int slow)
        {
            if (cacheTSI != null)
            {
                for (int idx = 0; idx < cacheTSI.Length; idx++)
                {
                    if (cacheTSI[idx].Fast == fast && cacheTSI[idx].Slow == slow && cacheTSI[idx].EqualsInput(input))
                    {
                        return(cacheTSI[idx]);
                    }
                }
            }

            lock (checkTSI)
            {
                checkTSI.Fast = fast;
                fast          = checkTSI.Fast;
                checkTSI.Slow = slow;
                slow          = checkTSI.Slow;

                if (cacheTSI != null)
                {
                    for (int idx = 0; idx < cacheTSI.Length; idx++)
                    {
                        if (cacheTSI[idx].Fast == fast && cacheTSI[idx].Slow == slow && cacheTSI[idx].EqualsInput(input))
                        {
                            return(cacheTSI[idx]);
                        }
                    }
                }

                TSI indicator = new TSI();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Fast  = fast;
                indicator.Slow  = slow;
                Indicators.Add(indicator);
                indicator.SetUp();

                TSI[] tmp = new TSI[cacheTSI == null ? 1 : cacheTSI.Length + 1];
                if (cacheTSI != null)
                {
                    cacheTSI.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheTSI            = tmp;
                return(indicator);
            }
        }
Exemple #2
0
        /// <summary>
        /// The TSI (True Strength Index) is a momentum-based indicator, developed by William Blau. Designed to determine both trend and overbought/oversold conditions, the TSI is applicable to intraday time frames as well as long term trading.
        /// </summary>
        /// <returns></returns>
        public TSI TSI(Data.IDataSeries input, int fast, int slow)
        {
            if (cacheTSI != null)
                for (int idx = 0; idx < cacheTSI.Length; idx++)
                    if (cacheTSI[idx].Fast == fast && cacheTSI[idx].Slow == slow && cacheTSI[idx].EqualsInput(input))
                        return cacheTSI[idx];

            lock (checkTSI)
            {
                checkTSI.Fast = fast;
                fast = checkTSI.Fast;
                checkTSI.Slow = slow;
                slow = checkTSI.Slow;

                if (cacheTSI != null)
                    for (int idx = 0; idx < cacheTSI.Length; idx++)
                        if (cacheTSI[idx].Fast == fast && cacheTSI[idx].Slow == slow && cacheTSI[idx].EqualsInput(input))
                            return cacheTSI[idx];

                TSI indicator = new TSI();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Fast = fast;
                indicator.Slow = slow;
                Indicators.Add(indicator);
                indicator.SetUp();

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