/// <summary>
        /// Plots the ratio value of the pair.
        /// </summary>
        /// <returns></returns>
        public PairsRatio PairsRatio(Data.IDataSeries input, string firstInstrument, string secondInstrument)
        {
            if (cachePairsRatio != null)
            {
                for (int idx = 0; idx < cachePairsRatio.Length; idx++)
                {
                    if (cachePairsRatio[idx].FirstInstrument == firstInstrument && cachePairsRatio[idx].SecondInstrument == secondInstrument && cachePairsRatio[idx].EqualsInput(input))
                    {
                        return(cachePairsRatio[idx]);
                    }
                }
            }

            lock (checkPairsRatio)
            {
                checkPairsRatio.FirstInstrument = firstInstrument;
                firstInstrument = checkPairsRatio.FirstInstrument;
                checkPairsRatio.SecondInstrument = secondInstrument;
                secondInstrument = checkPairsRatio.SecondInstrument;

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

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

                PairsRatio[] tmp = new PairsRatio[cachePairsRatio == null ? 1 : cachePairsRatio.Length + 1];
                if (cachePairsRatio != null)
                {
                    cachePairsRatio.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cachePairsRatio     = tmp;
                return(indicator);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Plots the ratio value of the pair.
        /// </summary>
        /// <returns></returns>
        public PairsRatio PairsRatio(Data.IDataSeries input, string firstInstrument, string secondInstrument)
        {
            if (cachePairsRatio != null)
                for (int idx = 0; idx < cachePairsRatio.Length; idx++)
                    if (cachePairsRatio[idx].FirstInstrument == firstInstrument && cachePairsRatio[idx].SecondInstrument == secondInstrument && cachePairsRatio[idx].EqualsInput(input))
                        return cachePairsRatio[idx];

            lock (checkPairsRatio)
            {
                checkPairsRatio.FirstInstrument = firstInstrument;
                firstInstrument = checkPairsRatio.FirstInstrument;
                checkPairsRatio.SecondInstrument = secondInstrument;
                secondInstrument = checkPairsRatio.SecondInstrument;

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

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

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