All indicators

Harmonic Pattern Detection

By LuxAlgoDec 27, 2021

Harmonic Pattern Detection is an indicator on Vela, our next-generation charting platform, written in Pine Script®.

Static chart image

Harmonic Pattern Detection turns manual harmonic work into a guided process: place the X, A, B, C, and D vertices directly on the chart, like a drawing tool, and the indicator classifies the structure as a Bat®, Gartley, Butterfly, or Crab®, labels each leg with its measured ratio, and projects the Potential Reversal Zone (PRZ) around point D. Classification is anchored to the harmonic ratio set, so a formation only earns a name when its segments measure within that pattern's ratio ranges. A dashboard confirms which pattern is currently identified, and an alert fires when price reaches the PRZ.

How to Trade the Harmonic Pattern Detection?

  • Dashboard label prints: once the vertices frame a valid Gartley, Bat, Butterfly, or Crab, the dashboard names it. Bullish patterns argue for longs at the PRZ, bearish for shorts.
  • Price enters the PRZ: the zone spans point D plus and minus 38.2% of the DX segment; treat it as an area to watch for reversal behavior rather than an exact price.
  • Hover the ratio labels: each ratio label lists that leg's reference ratios for all four patterns (Bat, Gartley, Butterfly, Crab), useful for judging how cleanly a formation fits.

Vertex placement is the whole game: the five points are adjusted on the chart itself rather than in the settings panel, so refining X, A, B and C (each read at the close of its bar) until the ratios line up is what separates a textbook pattern from a forced one. The D anchor only sets where D is drawn in time; its price is projected from the XA leg at the detected pattern's ratio.

Harmonic Pattern Detection Settings

  • XA Precision: the tolerance band around the AB retracement of XA for the Gartley (0.618) and Butterfly (0.786); the Bat, the Crab and every BC and CD check use fixed ranges. With the Gartley's ideal 0.618 XA leg and a precision of 0.01, anything from 0.608 to 0.628 qualifies. Keep it tight: overly wide values let the detection ranges of different patterns overlap, and the defaults are recommended.
  • Bullish (two color inputs, both titled Bullish in the settings panel): the first colors bullish patterns, the second bearish ones.

Frequently Asked Questions

Harmonic Trading was created by Scott M. Carney. Bat®, Crab®, Shark®, AB=CD® and 5-0® are registered trademarks of Scott M. Carney, referenced here under fair use to identify the patterns. LuxAlgo's tools are independent implementations and may differ from his official pattern definitions and software, available at HarmonicTrader.com. LuxAlgo is not affiliated with or endorsed by Scott M. Carney.

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

Also works on

TradingView
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.