protected override void OnCalculate(int startingIndex, int indexCount) { // Format of a TA method. //int startIdx, - mandatory //int endIdx, - mandatory //double[] inReal[added 0/1] or/and inOpen or/and inLow or/and inHigh or/and inClose //int/double optIn[NAME] or/and another one or none - parameters //out int outBegIdx, //out int outNBElement, //double/int[] out[Real/Integer] and or another one // Example: //TicTacTec.TA.Library.Core.RetCode code = TicTacTec.TA.Library.Core.Sma(0, indecesCount - 1, _closeResultValues, Period, out beginIndex, out number, ma); } // Consider the result returned. List <object> parameters = new List <object>(); parameters.Add(0); parameters.Add(indexCount - 1); int outBeginIdxPosition = 0; lock (this) { foreach (ParameterInfo info in _inputDefaultArrayParameters) { // parameters.Add(GetInputArrayValues(info.Name, startingIndex, indexCount)); parameters.Add(DataProvider.DataUnits); } foreach (object parameter in _inputParametersValues) { parameters.Add(parameter); } outBeginIdxPosition = parameters.Count; // outBeginIdx parameters.Add(0); // outNBElemenet parameters.Add(DataProvider.DataUnits.Count); foreach (ParameterInfo info in _outputArraysParameters) { if (info.ParameterType == typeof(double[])) {// Passed arrays must be prepared to the proper size. double[] array = new double[indexCount]; parameters.Add(array); } else if (info.ParameterType == typeof(int[])) {// Passed arrays must be prepared to the proper size. int[] array = new int[indexCount]; parameters.Add(array); } else { Console.WriteLine("Class operation logic error."); } } // This is how the normal call looks like. //TicTacTec.TA.Library.Core.Adx((int)parameters[0], (int)parameters[1], (double[])parameters[2], // (double[])parameters[3], (double[])parameters[4], (int)parameters[5], // out outBeginIdx, out outNBElemenet, (double[])parameters[8]); } object[] parametersArray = parameters.ToArray(); //TicTacTec.TA.Library.Core.RetCode code = (TicTacTec.TA.Library.Core.RetCode) // _methodInfo.Invoke(null, parametersArray); FxRSI fxi = new FxRSI(); int k = 0; foreach (BarData bar in (List <BarData>)parameters[2]) { ((double[])parameters[parameters.Count - 1])[k] = fxi.handleFullCandle(bar); k++; } lock (this) { int outBeginIdx = (int)parametersArray[outBeginIdxPosition]; int outNBElemenet = (int)parametersArray[outBeginIdxPosition + 1]; for (int i = 0; i < _outputArraysParameters.Count; i++) { int index = outBeginIdxPosition + 2 + i; if (parametersArray[index].GetType() == typeof(double[])) { Results.SetResultSetValues(_outputArraysParameters[i].Name, outBeginIdx, outNBElemenet, (double[])parametersArray[index]); } else if (parametersArray[index].GetType() == typeof(int[])) {// Valid scenario, implement. //SystemMonitor.NotImplementedCritical(); Results.SetResultSetValues(_outputArraysParameters[i].Name, outBeginIdx, outNBElemenet, GeneralHelper.IntsToDoubles((int[])parametersArray[index])); } } } }