예제 #1
0
        /// <summary>
        /// Using NT to manage IB positions
        /// </summary>
        /// <returns></returns>
        public ZZEquityCurveIB ZZEquityCurveIB(Data.IDataSeries input, string accountName, double accStopLoss, double accStopLossPct, string fileName, string ignoreSymbol)
        {
            if (cacheZZEquityCurveIB != null)
                for (int idx = 0; idx < cacheZZEquityCurveIB.Length; idx++)
                    if (cacheZZEquityCurveIB[idx].AccountName == accountName && Math.Abs(cacheZZEquityCurveIB[idx].AccStopLoss - accStopLoss) <= double.Epsilon && Math.Abs(cacheZZEquityCurveIB[idx].AccStopLossPct - accStopLossPct) <= double.Epsilon && cacheZZEquityCurveIB[idx].FileName == fileName && cacheZZEquityCurveIB[idx].IgnoreSymbol == ignoreSymbol && cacheZZEquityCurveIB[idx].EqualsInput(input))
                        return cacheZZEquityCurveIB[idx];

            lock (checkZZEquityCurveIB)
            {
                checkZZEquityCurveIB.AccountName = accountName;
                accountName = checkZZEquityCurveIB.AccountName;
                checkZZEquityCurveIB.AccStopLoss = accStopLoss;
                accStopLoss = checkZZEquityCurveIB.AccStopLoss;
                checkZZEquityCurveIB.AccStopLossPct = accStopLossPct;
                accStopLossPct = checkZZEquityCurveIB.AccStopLossPct;
                checkZZEquityCurveIB.FileName = fileName;
                fileName = checkZZEquityCurveIB.FileName;
                checkZZEquityCurveIB.IgnoreSymbol = ignoreSymbol;
                ignoreSymbol = checkZZEquityCurveIB.IgnoreSymbol;

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

                ZZEquityCurveIB indicator = new ZZEquityCurveIB();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.AccountName = accountName;
                indicator.AccStopLoss = accStopLoss;
                indicator.AccStopLossPct = accStopLossPct;
                indicator.FileName = fileName;
                indicator.IgnoreSymbol = ignoreSymbol;
                Indicators.Add(indicator);
                indicator.SetUp();

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

            lock (checkZZEquityCurveIB)
            {
                checkZZEquityCurveIB.AccountName = accountName;
                accountName = checkZZEquityCurveIB.AccountName;
                checkZZEquityCurveIB.AccStopLoss = accStopLoss;
                accStopLoss = checkZZEquityCurveIB.AccStopLoss;
                checkZZEquityCurveIB.AccStopLossPct = accStopLossPct;
                accStopLossPct = checkZZEquityCurveIB.AccStopLossPct;
                checkZZEquityCurveIB.FileName = fileName;
                fileName = checkZZEquityCurveIB.FileName;
                checkZZEquityCurveIB.IgnoreSymbol = ignoreSymbol;
                ignoreSymbol = checkZZEquityCurveIB.IgnoreSymbol;

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

                ZZEquityCurveIB indicator = new ZZEquityCurveIB();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input          = input;
                indicator.AccountName    = accountName;
                indicator.AccStopLoss    = accStopLoss;
                indicator.AccStopLossPct = accStopLossPct;
                indicator.FileName       = fileName;
                indicator.IgnoreSymbol   = ignoreSymbol;
                Indicators.Add(indicator);
                indicator.SetUp();

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