All indicators

Matrix Profile

By LuxAlgoApr 28, 2026

Matrix Profile is an indicator on Vela, our next-generation charting platform, written in Pine Script®.

Static chart image

Matrix Profile brings genuine all-pairs shape search to the chart, the first faithful implementation of the matrix profile in the library. Every 24-bar window of the last 400 bars is compared against every other, and each window's z-normalized distance to its nearest neighbor draws as a companion series: valleys are shapes that recurred, peaks are stretches unlike anything else in the sample, zero an exact repeat.

How to Trade the Matrix Profile?

  • Motifs (M1, M2): the lowest profile points extract as window pairs, boxed on the price chart: evidence a shape repeated, never that it predicts.
  • Discords (D1): the highest points mark windows with no good match anywhere, anomalies worth review as regime breaks, data errors or event reactions.
  • Current window match: the newest window and its nearest historical neighbor are outlined together, an analog pre-filter to re-rank with the finer machine learning tools.

Matrix Profile Settings

  • Source (default close) and Use First Differences (off): the series analyzed; differences match movement shape, not level path.
  • Window Length (m) (default 24): the scale of the shapes the profile can find.
  • Analysis Bars (n) (default 400): the sample the self-join scans.
  • Exclusion Zone (x m) (default 0.5): half-width of the skip zone suppressing trivial self-matches.
  • Motif Pairs (default 2) and Discords (default 1): extremes to extract, spaced an exclusion zone apart.
  • Motif Percentile (default 10.0) and Discord Percentile (default 90.0): the dashed guide levels and alert thresholds for the newest window.
  • Display: Current Window Match, Mark Motifs & Discords On Chart, Percentile Guides and Show Dashboard (all on), Profile Width (default 2).

Frequently Asked Questions

Free to use

Run it on Vela. Go further with a paid plan.

  • Up to 500 Custom Alerts, with webhook automation
  • Up to 10× the chart history of Free
  • Orderflow lookback up to full history
  • More Quant usage to customize it, plus extra usage when you need it
  • Futures data alongside crypto, stocks, forex and commodities
See plans
Original indicatorBuilt in-house by LuxAlgo

Run it on Vela. Make it yours with Quant.

Open this indicator free on Vela, our next-generation charting platform. Then ask Quant, our coding agent built into Vela, to retune it or turn it into a backtested strategy of your own.