コード例 #1
0
        /// <summary>
        /// Does not include results.
        /// </summary>
        /// <returns></returns>
        public override BasicIndicator SimpleClone()
        {
            Console.WriteLine((this.DataProvider != null).ToString());

            GenericTALibIndicator newIndicator = CreateInstance(_methodInfo, Description, Tradeable, ScaledToQuotes);

            newIndicator._inputDefaultArrayParameters = new List <ParameterInfo>(_inputDefaultArrayParameters);
            newIndicator._intputParameters            = new List <ParameterInfo>(_intputParameters);
            newIndicator._outputArraysParameters      = new List <ParameterInfo>(_outputArraysParameters);
            newIndicator._inputParametersValues       = (object[])_inputParametersValues.Clone();
            newIndicator._realInputArraySource        = _realInputArraySource;
            newIndicator._real1InputArraySource       = _real1InputArraySource;

            //GenericTALibIndicator newIndicator = (GenericTALibIndicator)this.MemberwiseClone();
            //// Still pointing to old indicator UI, deatach.
            //newIndicator._ui.IndicatorUIUpdatedEvent -= new PlatformIndicatorUI.IndicatorUIUpdatedDelegate(_ui_IndicatorUIUpdatedEvent);

            // Create and attach.
            //newIndicator._ui = new GenericTALibIndicatorUI(newIndicator);
            //newIndicator._ui.IndicatorUIUpdatedEvent += new PlatformIndicatorUI.IndicatorUIUpdatedDelegate(_ui_IndicatorUIUpdatedEvent);

            //lock (this)
            //{
            //    List<string> resultSetsNames = new List<string>();
            //    foreach (IndicatorResultSet set in _results.ResultSets)
            //    {
            //        resultSetsNames.Add(set.Name);
            //    }

            //    newIndicator._results = new IndicatorResults(newIndicator, resultSetsNames.ToArray());
            //}
            return(newIndicator);
        }
コード例 #2
0
        //void InitializeTaLibIndicator(MethodInfo methodInfo, string indicatorName, bool? isTradeable, bool? isScaledToQuotes, params object[] inputParameters)
        //{
        //    InitializeTaLibIndicator(methodInfo, indicatorName, isTradeable, isScaledToQuotes, null, null, inputParameters);
        //}

        void InitializeTaLibIndicator(MethodInfo methodInfo, string indicatorName, bool?isTradeable,
                                      bool?isScaledToQuotes, BarData.DataValueSourceEnum?inRealSource, BarData.DataValueSourceEnum?inReal1Source, params object[] inputParameters)
        {
            lock (this)
            {
                GenericTALibIndicator indicator = GenericTALibIndicator.CreateInstance(methodInfo, indicatorName, isTradeable, isScaledToQuotes);

                if (indicator == null)
                {
                    Console.WriteLine("Creating indicator [" + indicator.Name + "] failed.");
                    return;
                }

                Console.WriteLine(indicator.SetInputParameters(inputParameters));

                _indicatorsGroups[IndicatorGroups.Fxpa].Add(indicator.Name, indicator);
                indicator.RealInputArraySource  = inRealSource;
                indicator.Real1InputArraySource = inReal1Source;
            }
        }
コード例 #3
0
        // Parameters format of TaLibCore functions.
        //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);        }

        public static GenericTALibIndicator CreateInstance(MethodInfo methodInfo, string description, bool?isTradeable, bool?isScaledToQuotes)
        {
            if (methodInfo == null)
            {
                return(null);
            }

            Type returnType = methodInfo.ReturnType;

            if (returnType != typeof(TicTacTec.TA.Library.Core.RetCode))
            {
                return(null);
            }

            ParameterInfo[] parameters = methodInfo.GetParameters();
            if (parameters.Length < 5)
            {
                return(null);
            }

            int index = 0;

            if (parameters[index].ParameterType != typeof(int) ||
                parameters[index].Name != "startIdx")
            {
                return(null);
            }
            index++;

            if (parameters[index].ParameterType != typeof(int) ||
                parameters[index].Name != "endIdx")
            {
                return(null);
            }
            index++;

            List <ParameterInfo> indicatorParameters = new List <ParameterInfo>();

            while (parameters.Length > index && parameters[index].ParameterType == typeof(double[]))
            {
                if (parameters[index].Name != "inReal" &&
                    parameters[index].Name != "inReal0" &&
                    parameters[index].Name != "inReal1" &&
                    parameters[index].Name != "inHigh" &&
                    parameters[index].Name != "inLow" &&
                    parameters[index].Name != "inOpen" &&
                    parameters[index].Name != "inClose" &&
                    parameters[index].Name != "inVolume"
                    )
                {
                    return(null);
                }

                indicatorParameters.Add(parameters[index]);
                index++;
            }

            // optIn parameters
            List <ParameterInfo> indicatorInputParameters = new List <ParameterInfo>();

            while (parameters.Length > index && parameters[index].Name.StartsWith("optIn"))
            {
                if (parameters[index].ParameterType == typeof(int) ||
                    parameters[index].ParameterType != typeof(double) ||
                    parameters[index].ParameterType != typeof(TicTacTec.TA.Library.Core.MAType))
                {
                    indicatorInputParameters.Add(parameters[index]);
                }
                else
                {// Invalid type.
                    return(null);
                }
                index++;
            }

            if (parameters.Length <= index || parameters[index].IsOut == false ||
                parameters[index].Name != "outBegIdx")
            {
                return(null);
            }

            index++;

            if (parameters.Length <= index || parameters[index].IsOut == false ||
                parameters[index].Name != "outNBElement")
            {
                return(null);
            }

            index++;

            List <ParameterInfo> indicatorOutputArrayParameters      = new List <ParameterInfo>();
            List <string>        indicatorOutputArrayParametersNames = new List <string>();

            while (parameters.Length > index)
            {
                if (parameters[index].Name.StartsWith("out") == false)
                {
                    return(null);
                }

                if (parameters[index].ParameterType == typeof(double[]) ||
                    parameters[index].ParameterType == typeof(int[]))
                {
                    indicatorOutputArrayParametersNames.Add(parameters[index].Name);
                    indicatorOutputArrayParameters.Add(parameters[index]);
                }
                else
                {
                    return(null);
                }

                index++;
            }

            if (parameters.Length != index)
            {// Parameters left unknown.
                return(null);
            }

            GenericTALibIndicator indicator = new GenericTALibIndicator(methodInfo.Name, description, isTradeable, isScaledToQuotes, indicatorOutputArrayParametersNames.ToArray());

            indicator._inputDefaultArrayParameters.AddRange(indicatorParameters);
            indicator._outputArraysParameters.AddRange(indicatorOutputArrayParameters);
            indicator._intputParameters.AddRange(indicatorInputParameters);
            indicator._methodInfo = methodInfo;

            return(indicator);
        }
コード例 #4
0
 /// <summary>
 ///
 /// </summary>
 public GenericTALibIndicatorUI(GenericTALibIndicator indicator)
     : base(indicator)
 {
     Console.WriteLine(indicator.Name + "," + (indicator.DataProvider != null).ToString());
 }
        // Parameters format of TaLibCore functions.
        //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);        }
        public static GenericTALibIndicator CreateInstance(MethodInfo methodInfo, string description, bool? isTradeable, bool? isScaledToQuotes)
        {
            if (methodInfo == null)
            {
                return null;
            }

            Type returnType = methodInfo.ReturnType;

            if (returnType != typeof(TicTacTec.TA.Library.Core.RetCode))
            {
                return null;
            }

            ParameterInfo[] parameters = methodInfo.GetParameters();
            if (parameters.Length < 5)
            {
                return null;
            }

            int index = 0;

            if (parameters[index].ParameterType != typeof(int) ||
                parameters[index].Name != "startIdx")
            {
                return null;
            }
            index++;

            if (parameters[index].ParameterType != typeof(int) ||
                parameters[index].Name != "endIdx")
            {
                return null;
            }
            index++;

            List<ParameterInfo> indicatorParameters = new List<ParameterInfo>();
            while (parameters.Length > index && parameters[index].ParameterType == typeof(double[]))
            {
                if (parameters[index].Name != "inReal" &&
                    parameters[index].Name != "inReal0" &&
                    parameters[index].Name != "inReal1" &&
                    parameters[index].Name != "inHigh" &&
                    parameters[index].Name != "inLow" &&
                    parameters[index].Name != "inOpen" &&
                    parameters[index].Name != "inClose" &&
                    parameters[index].Name != "inVolume"
                    )
                {
                    return null;
                }

                indicatorParameters.Add(parameters[index]);
                index++;
            }

            // optIn parameters
            List<ParameterInfo> indicatorInputParameters = new List<ParameterInfo>();
            while(parameters.Length > index && parameters[index].Name.StartsWith("optIn"))
            {
                if (parameters[index].ParameterType == typeof(int) ||
                    parameters[index].ParameterType != typeof(double) ||
                    parameters[index].ParameterType != typeof(TicTacTec.TA.Library.Core.MAType))
                {
                    indicatorInputParameters.Add(parameters[index]);
                }
                else
                {// Invalid type.
                    return null;
                }
                index++;
            }

            if (parameters.Length <= index || parameters[index].IsOut == false
                || parameters[index].Name != "outBegIdx")
            {
                return null;
            }

            index++;

            if (parameters.Length <= index || parameters[index].IsOut == false
                || parameters[index].Name != "outNBElement")
            {
                return null;
            }

            index++;

            List<ParameterInfo> indicatorOutputArrayParameters = new List<ParameterInfo>();
            List<string> indicatorOutputArrayParametersNames = new List<string>();
            while (parameters.Length > index)
            {
                if (parameters[index].Name.StartsWith("out") == false)
                {
                    return null;
                }

                if (parameters[index].ParameterType == typeof(double[])
                    || parameters[index].ParameterType == typeof(int[]))
                {
                    indicatorOutputArrayParametersNames.Add(parameters[index].Name);
                    indicatorOutputArrayParameters.Add(parameters[index]);
                }
                else
                {
                    return null;
                }

                index++;
            }

            if (parameters.Length != index)
            {// Parameters left unknown.
                return null;
            }

            GenericTALibIndicator indicator = new GenericTALibIndicator(methodInfo.Name, description, isTradeable, isScaledToQuotes, indicatorOutputArrayParametersNames.ToArray());
            indicator._inputDefaultArrayParameters.AddRange(indicatorParameters);
            indicator._outputArraysParameters.AddRange(indicatorOutputArrayParameters);
            indicator._intputParameters.AddRange(indicatorInputParameters);
            indicator._methodInfo = methodInfo;

            return indicator;
        }
 /// <summary>
 /// 
 /// </summary>
 public GenericTALibIndicatorUI(GenericTALibIndicator indicator)
     : base(indicator)
 {
     Console.WriteLine(indicator.Name + "," + (indicator.DataProvider != null).ToString());
 }