コード例 #1
0
        /// <summary>
        /// Processes all charts after the frame bars in each has been updated.
        /// </summary>
        protected virtual void ProcessCharts()
        {
            if (_thrustDetector == null)
            {
                _thrustDetector = ObjectBase.Container.GetExportedValue <IPatternDetector>("ThrustDetector");
                _thrustDetector.Initialize(Parameters);
            }
            if (_thrustFactory == null)
            {
                _thrustFactory = ObjectBase.Container.GetExportedValue <IPatternFactory>("ThrustFactory");
                _thrustFactory.Initialize(Parameters);
            }

            foreach (Chart chart in _charts.Values)
            {
                Thrust thrust = (Thrust)chart.Patterns.FirstOrDefault(p => p.Type == MACC.Constants.SignalType.Thrust && (p.Active || p.StrategyTransactionID.HasValue));

                if (thrust == null)
                {
                    thrust = _thrustDetector.DetectPattern(chart) as Thrust;

                    if (thrust != null)
                    {
                        if (thrust.Active && thrust.SignalID == 0)
                        {
                            HandleNewThrust(chart, thrust);
                        }
                        else if (thrust.SignalID > 0)
                        {
                            HandleExistingThrust(chart, thrust);
                        }
                    }
                }
                else
                {
                    thrust = (Thrust)_thrustFactory.UpdatePattern(chart, thrust);
                    HandleExistingThrust(chart, thrust);
                }
            }
        }