/// <summary> /// Plots the RSI value of the pair. /// </summary> /// <returns></returns> public PairsRSI PairsRSI(Data.IDataSeries input, string firstInstrument, int rSIPeriod, string secondInstrument) { if (cachePairsRSI != null) { for (int idx = 0; idx < cachePairsRSI.Length; idx++) { if (cachePairsRSI[idx].FirstInstrument == firstInstrument && cachePairsRSI[idx].RSIPeriod == rSIPeriod && cachePairsRSI[idx].SecondInstrument == secondInstrument && cachePairsRSI[idx].EqualsInput(input)) { return(cachePairsRSI[idx]); } } } lock (checkPairsRSI) { checkPairsRSI.FirstInstrument = firstInstrument; firstInstrument = checkPairsRSI.FirstInstrument; checkPairsRSI.RSIPeriod = rSIPeriod; rSIPeriod = checkPairsRSI.RSIPeriod; checkPairsRSI.SecondInstrument = secondInstrument; secondInstrument = checkPairsRSI.SecondInstrument; if (cachePairsRSI != null) { for (int idx = 0; idx < cachePairsRSI.Length; idx++) { if (cachePairsRSI[idx].FirstInstrument == firstInstrument && cachePairsRSI[idx].RSIPeriod == rSIPeriod && cachePairsRSI[idx].SecondInstrument == secondInstrument && cachePairsRSI[idx].EqualsInput(input)) { return(cachePairsRSI[idx]); } } } PairsRSI indicator = new PairsRSI(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.FirstInstrument = firstInstrument; indicator.RSIPeriod = rSIPeriod; indicator.SecondInstrument = secondInstrument; Indicators.Add(indicator); indicator.SetUp(); PairsRSI[] tmp = new PairsRSI[cachePairsRSI == null ? 1 : cachePairsRSI.Length + 1]; if (cachePairsRSI != null) { cachePairsRSI.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cachePairsRSI = tmp; return(indicator); } }
/// <summary> /// Plots the RSI value of the pair. /// </summary> /// <returns></returns> public PairsRSI PairsRSI(Data.IDataSeries input, string firstInstrument, int rSIPeriod, string secondInstrument) { if (cachePairsRSI != null) for (int idx = 0; idx < cachePairsRSI.Length; idx++) if (cachePairsRSI[idx].FirstInstrument == firstInstrument && cachePairsRSI[idx].RSIPeriod == rSIPeriod && cachePairsRSI[idx].SecondInstrument == secondInstrument && cachePairsRSI[idx].EqualsInput(input)) return cachePairsRSI[idx]; lock (checkPairsRSI) { checkPairsRSI.FirstInstrument = firstInstrument; firstInstrument = checkPairsRSI.FirstInstrument; checkPairsRSI.RSIPeriod = rSIPeriod; rSIPeriod = checkPairsRSI.RSIPeriod; checkPairsRSI.SecondInstrument = secondInstrument; secondInstrument = checkPairsRSI.SecondInstrument; if (cachePairsRSI != null) for (int idx = 0; idx < cachePairsRSI.Length; idx++) if (cachePairsRSI[idx].FirstInstrument == firstInstrument && cachePairsRSI[idx].RSIPeriod == rSIPeriod && cachePairsRSI[idx].SecondInstrument == secondInstrument && cachePairsRSI[idx].EqualsInput(input)) return cachePairsRSI[idx]; PairsRSI indicator = new PairsRSI(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.FirstInstrument = firstInstrument; indicator.RSIPeriod = rSIPeriod; indicator.SecondInstrument = secondInstrument; Indicators.Add(indicator); indicator.SetUp(); PairsRSI[] tmp = new PairsRSI[cachePairsRSI == null ? 1 : cachePairsRSI.Length + 1]; if (cachePairsRSI != null) cachePairsRSI.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cachePairsRSI = tmp; return indicator; } }