Harmonic Patterns (XABCD) in a JavaScript or React Financial Chart
Harmonic patterns are price patterns whose legs are in particular Fibonacci ratios, such as the Gartley, Bat and Butterfly. Most are drawn as five points, X, A, B, C and D. This page explains what harmonic patterns are, the ratios that define them and how traders use them, and shows how to draw an XABCD pattern on a JavaScript or React financial chart with SciTrader.js, with live examples you can edit in CodePen.
The XABCD Pattern tool is one of the 34 drawing tools in the SciTrader SDK. For the full list, with each tool's id, annotation class and number of points, see Every Drawing Tool. To add drawing tools with point and click or in code, see Add Drawing Tools to a Financial Chart.
What Are Harmonic Patterns?
A harmonic pattern is a zigzag of four legs between five points, X, A, B, C and D:
- XA is the first move.
- AB retraces part of XA, and BC retraces part of AB.
- CD is the final leg, which ends at D, the point where the pattern "completes" and traders expect a reversal.
What makes a pattern harmonic is the ratio of each leg to the one before, from the Fibonacci sequence. The ABCD pattern is the same idea with only the last three legs.
SciTrader's XABCD Pattern tool, in the Patterns group, places six points, labelled 0, X, A, B, C and D: the leg into X, then the pattern's legs. It draws the legs and shades the triangles between them.
How Are Harmonic Pattern Ratios Calculated?
Each ratio compares the length of a leg, in price, with the leg before it: