예제 #1
0
        /// <summary>
        /// Alert on any pullback met requirment of AS
        /// </summary>
        /// <returns></returns>
        public AlertPullbacks AlertPullbacks(Data.IDataSeries input, bool useMACD, bool useMomentum)
        {
            if (cacheAlertPullbacks != null)
            {
                for (int idx = 0; idx < cacheAlertPullbacks.Length; idx++)
                {
                    if (cacheAlertPullbacks[idx].UseMACD == useMACD && cacheAlertPullbacks[idx].UseMomentum == useMomentum && cacheAlertPullbacks[idx].EqualsInput(input))
                    {
                        return(cacheAlertPullbacks[idx]);
                    }
                }
            }

            lock (checkAlertPullbacks)
            {
                checkAlertPullbacks.UseMACD = useMACD;
                useMACD = checkAlertPullbacks.UseMACD;
                checkAlertPullbacks.UseMomentum = useMomentum;
                useMomentum = checkAlertPullbacks.UseMomentum;

                if (cacheAlertPullbacks != null)
                {
                    for (int idx = 0; idx < cacheAlertPullbacks.Length; idx++)
                    {
                        if (cacheAlertPullbacks[idx].UseMACD == useMACD && cacheAlertPullbacks[idx].UseMomentum == useMomentum && cacheAlertPullbacks[idx].EqualsInput(input))
                        {
                            return(cacheAlertPullbacks[idx]);
                        }
                    }
                }

                AlertPullbacks indicator = new AlertPullbacks();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input       = input;
                indicator.UseMACD     = useMACD;
                indicator.UseMomentum = useMomentum;
                Indicators.Add(indicator);
                indicator.SetUp();

                AlertPullbacks[] tmp = new AlertPullbacks[cacheAlertPullbacks == null ? 1 : cacheAlertPullbacks.Length + 1];
                if (cacheAlertPullbacks != null)
                {
                    cacheAlertPullbacks.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheAlertPullbacks = tmp;
                return(indicator);
            }
        }
예제 #2
0
        /// <summary>
        /// Alert on any pullback met requirment of AS
        /// </summary>
        /// <returns></returns>
        public AlertPullbacks AlertPullbacks(Data.IDataSeries input, bool useMACD, bool useMomentum)
        {
            if (cacheAlertPullbacks != null)
                for (int idx = 0; idx < cacheAlertPullbacks.Length; idx++)
                    if (cacheAlertPullbacks[idx].UseMACD == useMACD && cacheAlertPullbacks[idx].UseMomentum == useMomentum && cacheAlertPullbacks[idx].EqualsInput(input))
                        return cacheAlertPullbacks[idx];

            lock (checkAlertPullbacks)
            {
                checkAlertPullbacks.UseMACD = useMACD;
                useMACD = checkAlertPullbacks.UseMACD;
                checkAlertPullbacks.UseMomentum = useMomentum;
                useMomentum = checkAlertPullbacks.UseMomentum;

                if (cacheAlertPullbacks != null)
                    for (int idx = 0; idx < cacheAlertPullbacks.Length; idx++)
                        if (cacheAlertPullbacks[idx].UseMACD == useMACD && cacheAlertPullbacks[idx].UseMomentum == useMomentum && cacheAlertPullbacks[idx].EqualsInput(input))
                            return cacheAlertPullbacks[idx];

                AlertPullbacks indicator = new AlertPullbacks();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.UseMACD = useMACD;
                indicator.UseMomentum = useMomentum;
                Indicators.Add(indicator);
                indicator.SetUp();

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