Пример #1
0
        /// <summary>
        /// This method is used to configure the strategy and is called once before any strategy method is called.
        /// </summary>
        protected override void MyInitialize()
        {

            if (_indi == null)
            {
                _indi = AmazingCrossoverIndi(_adxMin, _adxPeriod, _atrExclusionMultiplier, _atrPeriod,
                             _crossoverLookbackPeriod, _emaFastPeriod, _emaSlowPeriod, _rsiLower, _rsiPeriod,
                             _rsiUpper);
                _indi.SetupObjects();
                Add(_indi);
            }
            CalculateOnBarClose = true;
        }
        /// <summary>
        /// Enter the description of your new custom indicator here
        /// </summary>
        /// <returns></returns>
        public AmazingCrossoverIndi AmazingCrossoverIndi(Data.IDataSeries input, int aDXMinimum, int aDXPeriod, double aTRExclusionMultiplier, int aTRPeriod, int crossoverLookbackPeriod, int eMAFastPeriod, int eMASlowPeriod, int rSILower, int rSIPeriod, int rSIUpper)
        {
            if (cacheAmazingCrossoverIndi != null)
                for (int idx = 0; idx < cacheAmazingCrossoverIndi.Length; idx++)
                    if (cacheAmazingCrossoverIndi[idx].ADXMinimum == aDXMinimum && cacheAmazingCrossoverIndi[idx].ADXPeriod == aDXPeriod && Math.Abs(cacheAmazingCrossoverIndi[idx].ATRExclusionMultiplier - aTRExclusionMultiplier) <= double.Epsilon && cacheAmazingCrossoverIndi[idx].ATRPeriod == aTRPeriod && cacheAmazingCrossoverIndi[idx].CrossoverLookbackPeriod == crossoverLookbackPeriod && cacheAmazingCrossoverIndi[idx].EMAFastPeriod == eMAFastPeriod && cacheAmazingCrossoverIndi[idx].EMASlowPeriod == eMASlowPeriod && cacheAmazingCrossoverIndi[idx].RSILower == rSILower && cacheAmazingCrossoverIndi[idx].RSIPeriod == rSIPeriod && cacheAmazingCrossoverIndi[idx].RSIUpper == rSIUpper && cacheAmazingCrossoverIndi[idx].EqualsInput(input))
                        return cacheAmazingCrossoverIndi[idx];

            lock (checkAmazingCrossoverIndi)
            {
                checkAmazingCrossoverIndi.ADXMinimum = aDXMinimum;
                aDXMinimum = checkAmazingCrossoverIndi.ADXMinimum;
                checkAmazingCrossoverIndi.ADXPeriod = aDXPeriod;
                aDXPeriod = checkAmazingCrossoverIndi.ADXPeriod;
                checkAmazingCrossoverIndi.ATRExclusionMultiplier = aTRExclusionMultiplier;
                aTRExclusionMultiplier = checkAmazingCrossoverIndi.ATRExclusionMultiplier;
                checkAmazingCrossoverIndi.ATRPeriod = aTRPeriod;
                aTRPeriod = checkAmazingCrossoverIndi.ATRPeriod;
                checkAmazingCrossoverIndi.CrossoverLookbackPeriod = crossoverLookbackPeriod;
                crossoverLookbackPeriod = checkAmazingCrossoverIndi.CrossoverLookbackPeriod;
                checkAmazingCrossoverIndi.EMAFastPeriod = eMAFastPeriod;
                eMAFastPeriod = checkAmazingCrossoverIndi.EMAFastPeriod;
                checkAmazingCrossoverIndi.EMASlowPeriod = eMASlowPeriod;
                eMASlowPeriod = checkAmazingCrossoverIndi.EMASlowPeriod;
                checkAmazingCrossoverIndi.RSILower = rSILower;
                rSILower = checkAmazingCrossoverIndi.RSILower;
                checkAmazingCrossoverIndi.RSIPeriod = rSIPeriod;
                rSIPeriod = checkAmazingCrossoverIndi.RSIPeriod;
                checkAmazingCrossoverIndi.RSIUpper = rSIUpper;
                rSIUpper = checkAmazingCrossoverIndi.RSIUpper;

                if (cacheAmazingCrossoverIndi != null)
                    for (int idx = 0; idx < cacheAmazingCrossoverIndi.Length; idx++)
                        if (cacheAmazingCrossoverIndi[idx].ADXMinimum == aDXMinimum && cacheAmazingCrossoverIndi[idx].ADXPeriod == aDXPeriod && Math.Abs(cacheAmazingCrossoverIndi[idx].ATRExclusionMultiplier - aTRExclusionMultiplier) <= double.Epsilon && cacheAmazingCrossoverIndi[idx].ATRPeriod == aTRPeriod && cacheAmazingCrossoverIndi[idx].CrossoverLookbackPeriod == crossoverLookbackPeriod && cacheAmazingCrossoverIndi[idx].EMAFastPeriod == eMAFastPeriod && cacheAmazingCrossoverIndi[idx].EMASlowPeriod == eMASlowPeriod && cacheAmazingCrossoverIndi[idx].RSILower == rSILower && cacheAmazingCrossoverIndi[idx].RSIPeriod == rSIPeriod && cacheAmazingCrossoverIndi[idx].RSIUpper == rSIUpper && cacheAmazingCrossoverIndi[idx].EqualsInput(input))
                            return cacheAmazingCrossoverIndi[idx];

                AmazingCrossoverIndi indicator = new AmazingCrossoverIndi();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.ADXMinimum = aDXMinimum;
                indicator.ADXPeriod = aDXPeriod;
                indicator.ATRExclusionMultiplier = aTRExclusionMultiplier;
                indicator.ATRPeriod = aTRPeriod;
                indicator.CrossoverLookbackPeriod = crossoverLookbackPeriod;
                indicator.EMAFastPeriod = eMAFastPeriod;
                indicator.EMASlowPeriod = eMASlowPeriod;
                indicator.RSILower = rSILower;
                indicator.RSIPeriod = rSIPeriod;
                indicator.RSIUpper = rSIUpper;
                Indicators.Add(indicator);
                indicator.SetUp();

                AmazingCrossoverIndi[] tmp = new AmazingCrossoverIndi[cacheAmazingCrossoverIndi == null ? 1 : cacheAmazingCrossoverIndi.Length + 1];
                if (cacheAmazingCrossoverIndi != null)
                    cacheAmazingCrossoverIndi.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheAmazingCrossoverIndi = tmp;
                return indicator;
            }
        }
        /// <summary>
        /// Enter the description of your new custom indicator here
        /// </summary>
        /// <returns></returns>
        public AmazingCrossoverIndi AmazingCrossoverIndi(Data.IDataSeries input, int aDXMinimum, int aDXPeriod, double aTRExclusionMultiplier, int aTRPeriod, int crossoverLookbackPeriod, int eMAFastPeriod, int eMASlowPeriod, int rSILower, int rSIPeriod, int rSIUpper)
        {
            if (cacheAmazingCrossoverIndi != null)
            {
                for (int idx = 0; idx < cacheAmazingCrossoverIndi.Length; idx++)
                {
                    if (cacheAmazingCrossoverIndi[idx].ADXMinimum == aDXMinimum && cacheAmazingCrossoverIndi[idx].ADXPeriod == aDXPeriod && Math.Abs(cacheAmazingCrossoverIndi[idx].ATRExclusionMultiplier - aTRExclusionMultiplier) <= double.Epsilon && cacheAmazingCrossoverIndi[idx].ATRPeriod == aTRPeriod && cacheAmazingCrossoverIndi[idx].CrossoverLookbackPeriod == crossoverLookbackPeriod && cacheAmazingCrossoverIndi[idx].EMAFastPeriod == eMAFastPeriod && cacheAmazingCrossoverIndi[idx].EMASlowPeriod == eMASlowPeriod && cacheAmazingCrossoverIndi[idx].RSILower == rSILower && cacheAmazingCrossoverIndi[idx].RSIPeriod == rSIPeriod && cacheAmazingCrossoverIndi[idx].RSIUpper == rSIUpper && cacheAmazingCrossoverIndi[idx].EqualsInput(input))
                    {
                        return(cacheAmazingCrossoverIndi[idx]);
                    }
                }
            }

            lock (checkAmazingCrossoverIndi)
            {
                checkAmazingCrossoverIndi.ADXMinimum = aDXMinimum;
                aDXMinimum = checkAmazingCrossoverIndi.ADXMinimum;
                checkAmazingCrossoverIndi.ADXPeriod = aDXPeriod;
                aDXPeriod = checkAmazingCrossoverIndi.ADXPeriod;
                checkAmazingCrossoverIndi.ATRExclusionMultiplier = aTRExclusionMultiplier;
                aTRExclusionMultiplier = checkAmazingCrossoverIndi.ATRExclusionMultiplier;
                checkAmazingCrossoverIndi.ATRPeriod = aTRPeriod;
                aTRPeriod = checkAmazingCrossoverIndi.ATRPeriod;
                checkAmazingCrossoverIndi.CrossoverLookbackPeriod = crossoverLookbackPeriod;
                crossoverLookbackPeriod = checkAmazingCrossoverIndi.CrossoverLookbackPeriod;
                checkAmazingCrossoverIndi.EMAFastPeriod = eMAFastPeriod;
                eMAFastPeriod = checkAmazingCrossoverIndi.EMAFastPeriod;
                checkAmazingCrossoverIndi.EMASlowPeriod = eMASlowPeriod;
                eMASlowPeriod = checkAmazingCrossoverIndi.EMASlowPeriod;
                checkAmazingCrossoverIndi.RSILower = rSILower;
                rSILower = checkAmazingCrossoverIndi.RSILower;
                checkAmazingCrossoverIndi.RSIPeriod = rSIPeriod;
                rSIPeriod = checkAmazingCrossoverIndi.RSIPeriod;
                checkAmazingCrossoverIndi.RSIUpper = rSIUpper;
                rSIUpper = checkAmazingCrossoverIndi.RSIUpper;

                if (cacheAmazingCrossoverIndi != null)
                {
                    for (int idx = 0; idx < cacheAmazingCrossoverIndi.Length; idx++)
                    {
                        if (cacheAmazingCrossoverIndi[idx].ADXMinimum == aDXMinimum && cacheAmazingCrossoverIndi[idx].ADXPeriod == aDXPeriod && Math.Abs(cacheAmazingCrossoverIndi[idx].ATRExclusionMultiplier - aTRExclusionMultiplier) <= double.Epsilon && cacheAmazingCrossoverIndi[idx].ATRPeriod == aTRPeriod && cacheAmazingCrossoverIndi[idx].CrossoverLookbackPeriod == crossoverLookbackPeriod && cacheAmazingCrossoverIndi[idx].EMAFastPeriod == eMAFastPeriod && cacheAmazingCrossoverIndi[idx].EMASlowPeriod == eMASlowPeriod && cacheAmazingCrossoverIndi[idx].RSILower == rSILower && cacheAmazingCrossoverIndi[idx].RSIPeriod == rSIPeriod && cacheAmazingCrossoverIndi[idx].RSIUpper == rSIUpper && cacheAmazingCrossoverIndi[idx].EqualsInput(input))
                        {
                            return(cacheAmazingCrossoverIndi[idx]);
                        }
                    }
                }

                AmazingCrossoverIndi indicator = new AmazingCrossoverIndi();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input                   = input;
                indicator.ADXMinimum              = aDXMinimum;
                indicator.ADXPeriod               = aDXPeriod;
                indicator.ATRExclusionMultiplier  = aTRExclusionMultiplier;
                indicator.ATRPeriod               = aTRPeriod;
                indicator.CrossoverLookbackPeriod = crossoverLookbackPeriod;
                indicator.EMAFastPeriod           = eMAFastPeriod;
                indicator.EMASlowPeriod           = eMASlowPeriod;
                indicator.RSILower                = rSILower;
                indicator.RSIPeriod               = rSIPeriod;
                indicator.RSIUpper                = rSIUpper;
                Indicators.Add(indicator);
                indicator.SetUp();

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