Exemple #1
0
        /// <summary>
        /// Plots difference between two user defined instruments.
        /// </summary>
        /// <returns></returns>
        public Pairs Pairs(Data.IDataSeries input, string firstInstrument, string secondInstrument, int sMAPeriod)
        {
            if (cachePairs != null)
            {
                for (int idx = 0; idx < cachePairs.Length; idx++)
                {
                    if (cachePairs[idx].FirstInstrument == firstInstrument && cachePairs[idx].SecondInstrument == secondInstrument && cachePairs[idx].SMAPeriod == sMAPeriod && cachePairs[idx].EqualsInput(input))
                    {
                        return(cachePairs[idx]);
                    }
                }
            }

            lock (checkPairs)
            {
                checkPairs.FirstInstrument  = firstInstrument;
                firstInstrument             = checkPairs.FirstInstrument;
                checkPairs.SecondInstrument = secondInstrument;
                secondInstrument            = checkPairs.SecondInstrument;
                checkPairs.SMAPeriod        = sMAPeriod;
                sMAPeriod = checkPairs.SMAPeriod;

                if (cachePairs != null)
                {
                    for (int idx = 0; idx < cachePairs.Length; idx++)
                    {
                        if (cachePairs[idx].FirstInstrument == firstInstrument && cachePairs[idx].SecondInstrument == secondInstrument && cachePairs[idx].SMAPeriod == sMAPeriod && cachePairs[idx].EqualsInput(input))
                        {
                            return(cachePairs[idx]);
                        }
                    }
                }

                Pairs indicator = new Pairs();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input            = input;
                indicator.FirstInstrument  = firstInstrument;
                indicator.SecondInstrument = secondInstrument;
                indicator.SMAPeriod        = sMAPeriod;
                Indicators.Add(indicator);
                indicator.SetUp();

                Pairs[] tmp = new Pairs[cachePairs == null ? 1 : cachePairs.Length + 1];
                if (cachePairs != null)
                {
                    cachePairs.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cachePairs          = tmp;
                return(indicator);
            }
        }
Exemple #2
0
        /// <summary>
        /// Plots difference between two user defined instruments.
        /// </summary>
        /// <returns></returns>
        public Pairs Pairs(Data.IDataSeries input, string firstInstrument, string secondInstrument, int sMAPeriod)
        {
            if (cachePairs != null)
                for (int idx = 0; idx < cachePairs.Length; idx++)
                    if (cachePairs[idx].FirstInstrument == firstInstrument && cachePairs[idx].SecondInstrument == secondInstrument && cachePairs[idx].SMAPeriod == sMAPeriod && cachePairs[idx].EqualsInput(input))
                        return cachePairs[idx];

            lock (checkPairs)
            {
                checkPairs.FirstInstrument = firstInstrument;
                firstInstrument = checkPairs.FirstInstrument;
                checkPairs.SecondInstrument = secondInstrument;
                secondInstrument = checkPairs.SecondInstrument;
                checkPairs.SMAPeriod = sMAPeriod;
                sMAPeriod = checkPairs.SMAPeriod;

                if (cachePairs != null)
                    for (int idx = 0; idx < cachePairs.Length; idx++)
                        if (cachePairs[idx].FirstInstrument == firstInstrument && cachePairs[idx].SecondInstrument == secondInstrument && cachePairs[idx].SMAPeriod == sMAPeriod && cachePairs[idx].EqualsInput(input))
                            return cachePairs[idx];

                Pairs indicator = new Pairs();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.FirstInstrument = firstInstrument;
                indicator.SecondInstrument = secondInstrument;
                indicator.SMAPeriod = sMAPeriod;
                Indicators.Add(indicator);
                indicator.SetUp();

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