Esempio n. 1
0
        static void GetRSI(Rate[] rates)
        {
            //create the sample data
            Indicore.BarSourceAut source = CreateBarsData(rates);


            //find mva indicator
            Indicore.IndicatorCollectionAut indicators;
            indicators = (Indicore.IndicatorCollectionAut)core.Indicators;
            Indicore.IndicatorAut indicator = (Indicore.IndicatorAut)indicators["MVA"];
            //create parameter set and specify "N" parameter of the indicator.
            Indicore.IndicatorParameterCollectionAut parameters = (Indicore.IndicatorParameterCollectionAut)indicator.CreateParameterSet();
            ((Indicore.IndicatorParameterAut)(parameters["N"])).Value = 7;
            //create and instance of the indicator and force data update.
            Indicore.IndicatorInstanceAut instance = (Indicore.IndicatorInstanceAut)indicator.CreateIndicatorInstance(source, parameters);
            instance.Update(true);
            //get the indicator output (MVA has one output).
            Indicore.IndicatorOutputAut output = (Indicore.IndicatorOutputAut)((Indicore.IndicatorOutputCollectionAut)instance.Output)[0];

            //Print result.
            //Please note that the indicator output can be as longer as well as shorter than the indicator.
            //Also, the indicator results can start not from the first value of the source. The first defined value
            //of the indicator is in the output.FirstAvailable position.
            int max;

            if (source.Size > output.Size)
            {
                max = source.Size;
            }
            else
            {
                max = output.Size;
            }
            Console.WriteLine("{0}", instance.Name);
            Console.WriteLine("Date;Tick;MVA;");
            for (int i = 0; i < max; i++)
            {
                if (i < source.Size)
                {
                    Indicore.TickAut tick = (Indicore.TickAut)source[i];
                    Console.Write("{0};{1};", tick.Date, tick.Tick);
                }
                else
                {
                    Console.Write("n/a;n/a;");
                }

                if (i >= output.FirstAvailable && i < output.Size)
                {
                    Console.Write("{0};", output[i]);
                }
                else
                {
                    Console.Write("n/a;");
                }

                Console.WriteLine();
            }
        }
Esempio n. 2
0
        public static void List()
        {
            Indicore.IndicoreManagerAut core;
            //get marketscope path
            string path = (string)Registry.GetValue("HKEY_LOCAL_MACHINE\\Software\\CandleWorks\\FXOrder2Go", "InstallPath", "");

            //initialize and load indicators.
            core = new Indicore.IndicoreManagerAut();
            object errors;

            if (!core.LoadFromCAB(path + "\\indicators\\indicators.cab", out errors))
            {
                Console.WriteLine("Load standard: {0}", errors);
            }

            if (!core.LoadFromFolder(path + "\\indicators\\custom", out errors))
            {
                Console.WriteLine("Load custom: {0}", errors);
            }

            Indicore.IndicatorCollectionAut indicators;
            indicators = (Indicore.IndicatorCollectionAut)core.Indicators;

            foreach (Indicore.IndicatorAut indicator in indicators)
            {
                string type, req;

                if (indicator.Type == indicator.TYPE_OSCILLATOR)
                {
                    type = "oscillator";
                }
                else
                {
                    type = "indicator";
                }

                if (indicator.RequiredSource == indicator.SOURCE_BAR)
                {
                    req = "bars";
                }
                else
                {
                    req = "ticks";
                }

                Console.WriteLine("{0} {1} ({2}) of {3}", type, indicator.ID, indicator.Name, req);

                Indicore.IndicatorParameterCollectionAut parameters = (Indicore.IndicatorParameterCollectionAut)indicator.CreateParameterSet();
                foreach (Indicore.IndicatorParameterAut parameter in parameters)
                {
                    if (parameter.Type == parameter.TYPE_BOOL)
                    {
                        type = "Bool";
                    }
                    else if (parameter.Type == parameter.TYPE_INT)
                    {
                        type = "Int";
                    }
                    else if (parameter.Type == parameter.TYPE_DOUBLE)
                    {
                        type = "Double";
                    }
                    else if (parameter.Type == parameter.TYPE_STRING)
                    {
                        type = "String";
                    }
                    else if (parameter.Type == parameter.TYPE_COLOR)
                    {
                        type = "Color";
                    }
                    else
                    {
                        type = "Unknown";
                    }

                    Console.WriteLine("    {0} ({1}) : {2} = {3}", parameter.ID, parameter.Name, type, parameter.Default);
                }
            }
        }