# Search modes: DTW and Geo

<!-- machine twin: /api/legal/search-modes?format=md -->
<!-- version: 896f3cae4531 -->
# Search modes: DTW and Geo

DejaBars ships eight matching algorithms. They fall into three families, and they differ in
how strictly they compare two price curves.

## Geometric — the cheapest, and free

**Geo** simplifies both your pattern and every candidate window into straight segments using
Ramer–Douglas–Peucker, then compares the angles, the ratios between segments and the direction of
each turn.

- Speed: fast.
- Cost multiplier: 1 (free tier, with a free timeframe and a period up to 30 days).
- Best for: clean, clearly-shaped patterns you drew deliberately.

## Warping family — flexible shapes

| Algorithm | What it does | Cost multiplier |
|---|---|---|
| **DTW** (Dynamic Time Warping) | Classic shape match that allows a curve to stretch and compress in time | 2 |
| **WDTW** (Weighted DTW) | DTW with a penalty that grows with how far a point is warped | 6 |
| **ERP** (Edit distance with Real Penalty) | Edit-distance style comparison that tolerates gaps | 6 |
| **LCSS** (Longest Common Subsequence) | Matches the shared subsequence and ignores outliers | 6 |

These find shapes that appear at a different speed than you drew them, which is why they are the
most expensive to run.

## Statistical family — exact, very fast

| Algorithm | What it does | Cost multiplier |
|---|---|---|
| **Matrix Profile** | Finds every repeated subsequence of the same length across the series | 3 |
| **Cross-Correlation** | Sliding-window Pearson correlation; finds near-exact copies of your template | 3 |
| **SAX** | Symbolic aggregate approximation; compares coarse shape signatures | 3 |

Matrix Profile and Cross-Correlation require the candidate window to match your pattern's length,
so they are precise but rigid. SAX is a middle ground.

## Which should I use?

1. Start with **Geo**: instant, free, and it handles most hand-drawn shapes.
2. If too little comes back, move to **DTW**: it tolerates different speeds.
3. If you want exact repeats of a specific template, use **Cross-Correlation** or **Matrix Profile**.
4. Reach for **WDTW / ERP / LCSS** when the shape matters but timing varies a lot — they cost the most.

## Cost

A search costs `timeframe × algorithm × period` tokens; the free tier (Geo, 1h–1w timeframe,
period up to 30 days) is free. See [Tokens, plans and allowances](/docs/tokens-and-plans).
