コード例 #1
0
        public RandomStrategy(ref PluginServices pluginService, int minind, int maxind, int minper, int maxper, bool disposition)
        {
            _randomClass   = new Random();
            _indicators    = new ArrayList();
            _entryName     = "";
            _pluginService = pluginService;
            _minIndicators = minind;
            _maxIndicators = maxind;
            _minPeriod     = minper;
            _maxPeriod     = maxper;
            Disposition    = disposition;
            int indicators = _randomClass.Next(_minIndicators, _maxIndicators + 1);

            for (int i = 0; i < indicators; i++)
            {
                int indicator = _randomClass.Next(1, _pluginService.AvailablePlugins.Count + 1) - 1;
                int period    = _randomClass.Next(_minPeriod, _maxPeriod);
                AvailablePlugin <IIndicator> plug = _pluginService.AvailablePlugins[indicator];
                Assembly pluginAssembly           = Assembly.LoadFrom(plug.AssemblyPath);
                plug.Instance = (IIndicator)Activator.CreateInstance(pluginAssembly.GetType(plug.PlugType.ToString()), period);
                IIndicator rne = plug.Instance;
                _indicators.Add(rne);
            }
            if (Disposition == true)
            {
                _entryName = GetSortedName(_indicators);
            }
            else
            {
                _exitName = GetSortedName(_indicators);
            }
        }
コード例 #2
0
 public TestStrategy(ref PluginServices pluginService, string strategy, bool disposition)
 {
     _pluginService = pluginService;
     _strategy      = strategy;
     Disposition    = disposition;
     Resolve();
     Initialize();
 }
コード例 #3
0
 /// <summary>
 /// Genetic strategy constructor
 /// </summary>
 public GeneticStrategy(ref PluginServices pluginService, ArrayList entry, ArrayList exit)
 {
     _pluginService     = pluginService;
     _entryIndicators   = Resolve(entry);
     EntryIndicatorName = GetSortedName(_entryIndicators);
     _exitIndicators    = Resolve(exit);
     ExitIndicatorName  = GetSortedName(_exitIndicators);
     Initialize();
 }
コード例 #4
0
        public RandomStrategy(ref PluginServices pluginService, int maxind, int maxper)
        {
            _randomClass   = new Random();
            _indicators    = new ArrayList();
            _entryName     = "";
            _pluginService = pluginService;
            _maxIndicators = maxind;
            _maxPeriod     = maxper;
            int indicators = _randomClass.Next(1, _maxIndicators + 1);

            for (int i = 0; i < indicators; i++)
            {
                int indicator = _randomClass.Next(1, _pluginService.AvailablePlugins.Count + 1) - 1;
                int period    = _randomClass.Next(1, _maxPeriod);
                AvailablePlugin <IIndicator> plug = _pluginService.AvailablePlugins[indicator];
                Assembly pluginAssembly           = Assembly.LoadFrom(plug.AssemblyPath);
                plug.Instance = (IIndicator)Activator.CreateInstance(pluginAssembly.GetType(plug.PlugType.ToString()), period);
                IIndicator rne = plug.Instance;
                _indicators.Add(rne);
            }
            if (Disposition == true)
            {
                for (int i = 0; i < _indicators.Count; i++)
                {
                    _entryName += ((IIndicator)_indicators[i]).GetName();
                    if (i != _indicators.Count - 1)
                    {
                        _entryName += ":";
                    }
                }
            }
            else
            {
                for (int i = 0; i < _indicators.Count; i++)
                {
                    _exitName += ((IIndicator)_indicators[i]).GetName();
                    if (i != _indicators.Count - 1)
                    {
                        _exitName += ":";
                    }
                }
            }

            /*
             *          if (_exitFlag == true)
             *          {
             *              _exitIndicators.Add(new StandardExit(_maximumHoldingPeriodBars, _profitTragetVolatilityUnits, _moneyManagementStopVolatilityUnits));
             *
             *              for (int i = 0; i < _exitIndicators.Count; i++)
             *              {
             *                  ExitIndicatorName += ((IIndicator)_exitIndicators[i]).GetName();
             *                  if (i != _exitIndicators.Count - 1)
             *                      ExitIndicatorName += ":";
             *              }
             *          }
             */
        }
コード例 #5
0
        /// <summary>
        /// Genetic strategy constructor
        /// </summary>
        public GeneticStrategy(ref PluginServices pluginService, string genome)
        {
            _pluginService = pluginService;
            string[] dataArray = new string[2];
            Regex    rex       = new Regex("&(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");

            dataArray          = rex.Split(genome);
            _entryIndicators   = Resolve(dataArray[0]);
            EntryIndicatorName = GetSortedName(_entryIndicators);
            _exitIndicators    = Resolve(dataArray[1]);
            ExitIndicatorName  = GetSortedName(_exitIndicators);
            Initialize();
        }