Example #1
0
        /// <summary>
        /// Variation of the VOL (Volume) indicator that colors the volume histogram different color depending if the current bar is up or down bar
        /// </summary>
        /// <returns></returns>
        public ZZVolumeSpikeAlert ZZVolumeSpikeAlert(Data.IDataSeries input, bool alertEnabled)
        {
            if (cacheZZVolumeSpikeAlert != null)
            {
                for (int idx = 0; idx < cacheZZVolumeSpikeAlert.Length; idx++)
                {
                    if (cacheZZVolumeSpikeAlert[idx].AlertEnabled == alertEnabled && cacheZZVolumeSpikeAlert[idx].EqualsInput(input))
                    {
                        return(cacheZZVolumeSpikeAlert[idx]);
                    }
                }
            }

            lock (checkZZVolumeSpikeAlert)
            {
                checkZZVolumeSpikeAlert.AlertEnabled = alertEnabled;
                alertEnabled = checkZZVolumeSpikeAlert.AlertEnabled;

                if (cacheZZVolumeSpikeAlert != null)
                {
                    for (int idx = 0; idx < cacheZZVolumeSpikeAlert.Length; idx++)
                    {
                        if (cacheZZVolumeSpikeAlert[idx].AlertEnabled == alertEnabled && cacheZZVolumeSpikeAlert[idx].EqualsInput(input))
                        {
                            return(cacheZZVolumeSpikeAlert[idx]);
                        }
                    }
                }

                ZZVolumeSpikeAlert indicator = new ZZVolumeSpikeAlert();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input        = input;
                indicator.AlertEnabled = alertEnabled;
                Indicators.Add(indicator);
                indicator.SetUp();

                ZZVolumeSpikeAlert[] tmp = new ZZVolumeSpikeAlert[cacheZZVolumeSpikeAlert == null ? 1 : cacheZZVolumeSpikeAlert.Length + 1];
                if (cacheZZVolumeSpikeAlert != null)
                {
                    cacheZZVolumeSpikeAlert.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]     = indicator;
                cacheZZVolumeSpikeAlert = tmp;
                return(indicator);
            }
        }
        /// <summary>
        /// Variation of the VOL (Volume) indicator that colors the volume histogram different color depending if the current bar is up or down bar
        /// </summary>
        /// <returns></returns>
        public ZZVolumeSpikeAlert ZZVolumeSpikeAlert(Data.IDataSeries input, bool alertEnabled)
        {
            if (cacheZZVolumeSpikeAlert != null)
                for (int idx = 0; idx < cacheZZVolumeSpikeAlert.Length; idx++)
                    if (cacheZZVolumeSpikeAlert[idx].AlertEnabled == alertEnabled && cacheZZVolumeSpikeAlert[idx].EqualsInput(input))
                        return cacheZZVolumeSpikeAlert[idx];

            lock (checkZZVolumeSpikeAlert)
            {
                checkZZVolumeSpikeAlert.AlertEnabled = alertEnabled;
                alertEnabled = checkZZVolumeSpikeAlert.AlertEnabled;

                if (cacheZZVolumeSpikeAlert != null)
                    for (int idx = 0; idx < cacheZZVolumeSpikeAlert.Length; idx++)
                        if (cacheZZVolumeSpikeAlert[idx].AlertEnabled == alertEnabled && cacheZZVolumeSpikeAlert[idx].EqualsInput(input))
                            return cacheZZVolumeSpikeAlert[idx];

                ZZVolumeSpikeAlert indicator = new ZZVolumeSpikeAlert();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.AlertEnabled = alertEnabled;
                Indicators.Add(indicator);
                indicator.SetUp();

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