private void DetectPattern(IPatternDetector detector) { listViewPatterns.Items.Clear(); listViewPatterns.Items.AddRange(detector.DetectAsListViewItems(LogProvider).ToArray()); labelCount.Text = "Total: " + listViewPatterns.Items.Count; }
/// <summary> /// Write a method that receive and array/list and returns if it is a wave crest, wave trough /// or nothing. /// </summary> /// <param name="crestDetector"></param> /// <param name="troughDetector"></param> public WavePatternDetector(IPatternDetector <int> crestDetector, IPatternDetector <int> troughDetector) { if (crestDetector == null || troughDetector == null) { throw new ArgumentNullException(); } if (crestDetector.GetType() != typeof(CrestPatternDetector) && troughDetector.GetType() != typeof(TroughPatternDetector)) { throw new ArgumentException("Wrong pattern detector has been inputted"); } this.crestDetector = crestDetector; this.troughDetector = troughDetector; }
private void buttonDetectPatterns_Click(object sender, EventArgs e) { // Make sure that something is selected. if (comboDetectors.SelectedIndex < 0 || comboDetectors.SelectedIndex >= comboDetectors.Items.Count) { // Do nothing in these cases return; } Type baseType = typeof(AbstractPatternDetector); Assembly assembly = baseType.Assembly; string detectorName = comboDetectors.Items[comboDetectors.SelectedIndex].ToString(); Type detectorType = assembly.GetType(baseType.Namespace + "." + detectorName); MethodInfo instanceGetter = detectorType.GetMethod("GetInstance", BindingFlags.NonPublic | BindingFlags.Static); IPatternDetector patternDetector = instanceGetter.Invoke(null, null) as IPatternDetector; DetectPattern(patternDetector); }
/// <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); } } }
public void Setup(IPatternDetector <int> detector, int[] array) { this.patternDetector = detector; this.patternDetector.SetDataForPatternDetection(array); }