Exemple #1
0
        /// <summary>
        /// Using NT to manage IB positions
        /// </summary>
        /// <returns></returns>
        public ZZManageAccountPositions ZZManageAccountPositions(Data.IDataSeries input, double accStopLoss, double accStopLossPct, string ignoreSymbol, string ignoreSymbol2)
        {
            if (cacheZZManageAccountPositions != null)
            {
                for (int idx = 0; idx < cacheZZManageAccountPositions.Length; idx++)
                {
                    if (Math.Abs(cacheZZManageAccountPositions[idx].AccStopLoss - accStopLoss) <= double.Epsilon && Math.Abs(cacheZZManageAccountPositions[idx].AccStopLossPct - accStopLossPct) <= double.Epsilon && cacheZZManageAccountPositions[idx].IgnoreSymbol == ignoreSymbol && cacheZZManageAccountPositions[idx].IgnoreSymbol2 == ignoreSymbol2 && cacheZZManageAccountPositions[idx].EqualsInput(input))
                    {
                        return(cacheZZManageAccountPositions[idx]);
                    }
                }
            }

            lock (checkZZManageAccountPositions)
            {
                checkZZManageAccountPositions.AccStopLoss = accStopLoss;
                accStopLoss = checkZZManageAccountPositions.AccStopLoss;
                checkZZManageAccountPositions.AccStopLossPct = accStopLossPct;
                accStopLossPct = checkZZManageAccountPositions.AccStopLossPct;
                checkZZManageAccountPositions.IgnoreSymbol = ignoreSymbol;
                ignoreSymbol = checkZZManageAccountPositions.IgnoreSymbol;
                checkZZManageAccountPositions.IgnoreSymbol2 = ignoreSymbol2;
                ignoreSymbol2 = checkZZManageAccountPositions.IgnoreSymbol2;

                if (cacheZZManageAccountPositions != null)
                {
                    for (int idx = 0; idx < cacheZZManageAccountPositions.Length; idx++)
                    {
                        if (Math.Abs(cacheZZManageAccountPositions[idx].AccStopLoss - accStopLoss) <= double.Epsilon && Math.Abs(cacheZZManageAccountPositions[idx].AccStopLossPct - accStopLossPct) <= double.Epsilon && cacheZZManageAccountPositions[idx].IgnoreSymbol == ignoreSymbol && cacheZZManageAccountPositions[idx].IgnoreSymbol2 == ignoreSymbol2 && cacheZZManageAccountPositions[idx].EqualsInput(input))
                        {
                            return(cacheZZManageAccountPositions[idx]);
                        }
                    }
                }

                ZZManageAccountPositions indicator = new ZZManageAccountPositions();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input          = input;
                indicator.AccStopLoss    = accStopLoss;
                indicator.AccStopLossPct = accStopLossPct;
                indicator.IgnoreSymbol   = ignoreSymbol;
                indicator.IgnoreSymbol2  = ignoreSymbol2;
                Indicators.Add(indicator);
                indicator.SetUp();

                ZZManageAccountPositions[] tmp = new ZZManageAccountPositions[cacheZZManageAccountPositions == null ? 1 : cacheZZManageAccountPositions.Length + 1];
                if (cacheZZManageAccountPositions != null)
                {
                    cacheZZManageAccountPositions.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]           = indicator;
                cacheZZManageAccountPositions = tmp;
                return(indicator);
            }
        }
        /// <summary>
        /// Using NT to manage IB positions
        /// </summary>
        /// <returns></returns>
        public ZZManageAccountPositions ZZManageAccountPositions(Data.IDataSeries input, double accStopLoss, double accStopLossPct, string ignoreSymbol, string ignoreSymbol2)
        {
            if (cacheZZManageAccountPositions != null)
                for (int idx = 0; idx < cacheZZManageAccountPositions.Length; idx++)
                    if (Math.Abs(cacheZZManageAccountPositions[idx].AccStopLoss - accStopLoss) <= double.Epsilon && Math.Abs(cacheZZManageAccountPositions[idx].AccStopLossPct - accStopLossPct) <= double.Epsilon && cacheZZManageAccountPositions[idx].IgnoreSymbol == ignoreSymbol && cacheZZManageAccountPositions[idx].IgnoreSymbol2 == ignoreSymbol2 && cacheZZManageAccountPositions[idx].EqualsInput(input))
                        return cacheZZManageAccountPositions[idx];

            lock (checkZZManageAccountPositions)
            {
                checkZZManageAccountPositions.AccStopLoss = accStopLoss;
                accStopLoss = checkZZManageAccountPositions.AccStopLoss;
                checkZZManageAccountPositions.AccStopLossPct = accStopLossPct;
                accStopLossPct = checkZZManageAccountPositions.AccStopLossPct;
                checkZZManageAccountPositions.IgnoreSymbol = ignoreSymbol;
                ignoreSymbol = checkZZManageAccountPositions.IgnoreSymbol;
                checkZZManageAccountPositions.IgnoreSymbol2 = ignoreSymbol2;
                ignoreSymbol2 = checkZZManageAccountPositions.IgnoreSymbol2;

                if (cacheZZManageAccountPositions != null)
                    for (int idx = 0; idx < cacheZZManageAccountPositions.Length; idx++)
                        if (Math.Abs(cacheZZManageAccountPositions[idx].AccStopLoss - accStopLoss) <= double.Epsilon && Math.Abs(cacheZZManageAccountPositions[idx].AccStopLossPct - accStopLossPct) <= double.Epsilon && cacheZZManageAccountPositions[idx].IgnoreSymbol == ignoreSymbol && cacheZZManageAccountPositions[idx].IgnoreSymbol2 == ignoreSymbol2 && cacheZZManageAccountPositions[idx].EqualsInput(input))
                            return cacheZZManageAccountPositions[idx];

                ZZManageAccountPositions indicator = new ZZManageAccountPositions();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.AccStopLoss = accStopLoss;
                indicator.AccStopLossPct = accStopLossPct;
                indicator.IgnoreSymbol = ignoreSymbol;
                indicator.IgnoreSymbol2 = ignoreSymbol2;
                Indicators.Add(indicator);
                indicator.SetUp();

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