Skip to content

Pattern Recognition Plugin

The Pattern Recognition plugin provides a powerful engine for identifying geometric and technical patterns in time-series and financial data. It supports a wide range of built-in classic chart patterns and allows developers to define custom pattern validators.

Features

  • Built-in Catalog: Covers Head & Shoulders, Double Top/Bottom, Triangles, Wedges, Flags, and more.
  • Real-time Detection: Monitor streaming data and get notified the moment a pattern is completed.
  • Custom Pattern Engine: Define your own geometric constraints and sequences.
  • Automatic Visualization: Built-in annotations and dashed lines to highlight detected patterns.
  • Confidence Scoring: Each match includes a confidence level (0.0 to 1.0) based on mathematical strictlyness.
  • Volume & Trend Confirmation: Optionally require volume confirmation for technical breakout patterns.

Basic Usage

typescript
import { createChart, PluginPatternRecognition } from 'scichart-engine';

const chart = createChart({ container });

// Enable pattern recognition
await chart.use(PluginPatternRecognition({
  defaultParameters: {
    minConfidence: 0.8,
    patternTypes: ['head-shoulders', 'double-top', 'ascending-triangle']
  },
  enableRealtime: true,
  visualization: {
    showPatterns: true,
    showLabels: true,
    colorScheme: {
      'head-shoulders': '#ff6b6b',
      'ascending-triangle': '#45b7d1'
    }
  }
}));

// Listen for detections
chart.events.on('pattern:detected', ({ match, seriesId }) => {
  console.log(`Detected ${match.pattern.name} in ${seriesId} with ${Math.round(match.confidence * 100)}% confidence`);
});

API Reference

chart.patterns

The plugin exposes its methods through the chart.patterns namespace.

typescript
// Manually run detection on a dataset
const result = await chart.patterns.detectPatterns('series-1', dataPoints);

// Register a new custom pattern
chart.patterns.registerCustomPattern({
  id: 'my-spike',
  name: 'Volatile Spike',
  pointSequence: [
    { constraints: { lowerThanPrevious: true } },
    { constraints: { higherThanPrevious: true } },
    { constraints: { lowerThanPrevious: true } }
  ]
});

// Enable/Disable real-time monitoring for a specific series
chart.patterns.enableRealtimeDetection('main-ticker');

Supported Pattern Types

CategoryTypical Patterns
Reversalhead-shoulders, double-top, double-bottom, triple-top
Continuationflag, pennant, rectangle
Consolidationascending-triangle, descending-triangle, symmetrical-triangle
Exhaustionrising-wedge, falling-wedge

Configuration Options

PropertyTypeDefaultDescription
minConfidencenumber0.7Minimum match accuracy to report a pattern.
sensitivitynumber0.5How strictly to filter noise before detection.
maxPatternsnumber10Maximum patterns to keep active per series.
debounceTimenumber500Delay in ms before re-scanning after data updates.
visualization.opacitynumber0.7Opacity of the pattern overlays.

Performance Tips

  1. Limit Series: Only enable real-time detection on the primary series you are monitoring.
  2. Adjust Sensitivity: For noisy data, increase the sensitivity parameter to ignore micro-fluctuations.
  3. Use Debouncing: The default debounceTime ensures calculations don't happen on every single point in a high-speed stream.

See Also

Released under the MIT License.