예제 #1
0
        /// <summary>
        /// Sends an alert to the alert window when a price level has been reached.
        /// </summary>
        /// <returns></returns>
        public PriceAlert PriceAlert_New(Data.IDataSeries input, double price, bool showTriggerLine)
        {
            if (cachePriceAlert != null)
            {
                for (int idx = 0; idx < cachePriceAlert.Length; idx++)
                {
                    if (Math.Abs(cachePriceAlert[idx].Price - price) <= double.Epsilon && cachePriceAlert[idx].ShowTriggerLine == showTriggerLine && cachePriceAlert[idx].EqualsInput(input))
                    {
                        return(cachePriceAlert[idx]);
                    }
                }
            }

            lock (checkPriceAlert)
            {
                checkPriceAlert.Price = price;
                price = checkPriceAlert.Price;
                checkPriceAlert.ShowTriggerLine = showTriggerLine;
                showTriggerLine = checkPriceAlert.ShowTriggerLine;

                if (cachePriceAlert != null)
                {
                    for (int idx = 0; idx < cachePriceAlert.Length; idx++)
                    {
                        if (Math.Abs(cachePriceAlert[idx].Price - price) <= double.Epsilon && cachePriceAlert[idx].ShowTriggerLine == showTriggerLine && cachePriceAlert[idx].EqualsInput(input))
                        {
                            return(cachePriceAlert[idx]);
                        }
                    }
                }

                PriceAlert indicator = new PriceAlert();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input           = input;
                indicator.Price           = price;
                indicator.ShowTriggerLine = showTriggerLine;
                Indicators.Add(indicator);
                indicator.SetUp();

                PriceAlert[] tmp = new PriceAlert[cachePriceAlert == null ? 1 : cachePriceAlert.Length + 1];
                if (cachePriceAlert != null)
                {
                    cachePriceAlert.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cachePriceAlert     = tmp;
                return(indicator);
            }
        }
예제 #2
0
        /// <summary>
        /// Sends an alert to the alert window when a price level has been reached.
        /// </summary>
        /// <returns></returns>
        public PriceAlert PriceAlert_New(Data.IDataSeries input, double price, bool showTriggerLine)
        {
            if (cachePriceAlert != null)
                for (int idx = 0; idx < cachePriceAlert.Length; idx++)
                    if (Math.Abs(cachePriceAlert[idx].Price - price) <= double.Epsilon && cachePriceAlert[idx].ShowTriggerLine == showTriggerLine && cachePriceAlert[idx].EqualsInput(input))
                        return cachePriceAlert[idx];

            lock (checkPriceAlert)
            {
                checkPriceAlert.Price = price;
                price = checkPriceAlert.Price;
                checkPriceAlert.ShowTriggerLine = showTriggerLine;
                showTriggerLine = checkPriceAlert.ShowTriggerLine;

                if (cachePriceAlert != null)
                    for (int idx = 0; idx < cachePriceAlert.Length; idx++)
                        if (Math.Abs(cachePriceAlert[idx].Price - price) <= double.Epsilon && cachePriceAlert[idx].ShowTriggerLine == showTriggerLine && cachePriceAlert[idx].EqualsInput(input))
                            return cachePriceAlert[idx];

                PriceAlert indicator = new PriceAlert();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Price = price;
                indicator.ShowTriggerLine = showTriggerLine;
                Indicators.Add(indicator);
                indicator.SetUp();

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