PatternsHunters

Harmonic Scanner

This script detects harmonic formations: Gartley , Bat, Butterfly , and Crab .

Unlike the other harmonic scanners, it analyzes more than the last five consecutive points. It checks up to 50 last high/low points and tries to find a pattern there. It also labels point D with information on what type of formation it is and if it's a signal to sell or buy.

The default error margin for each formation is 5% (so each point can be up to 5% different than the ideal value defined in the books).
I don't have enough reputation for linking other charts, but check it out with BATS:V (Visa) and BATS:JPM (JPMorgan Chase) to see more formations.
Release Notes: First fix :) I fixed the direction of labels, so they don't always point up, but they point up/down depending if they are on high/low points of the chart.
Release Notes: I'm republishing the release notes, because the previous version contained illegal link to our website (where we published a detailed tutorial on how to use this script)

Version 1.1 - first bigger update of the script:
  • Added "Alternate Bat", "Deep Crab", "Shark", and "Cypher" formations
  • Changed color of the "No formation" labels
  • Added option to modify the depth of the ZigZag. Low depth means lots of high/low points, but the script is slower. High depth means fewer high/low points, and the script is faster, but it might miss some points that are close to each other.
  • Added option to display the ZigZag formation (detecting formations is based on high/low points from the ZigZag pattern - you can now display the ZigZag to see which points are being checked).
  • Added option to hide "No formation" labels
Release Notes: Version 1.2: Configurable error margin, additional display options, and stability improvements

  • Configurable error tolerance (as requested by some users) - you can set how many % the detected formation can differ from the "ideal" formation.
  • Zigzag and formation lines' width can be adjusted in the configuration
  • The script is more stable and no longer crashes after a few new bars (when used with a small interval like seconds or minutes).
Release Notes: Version 1.3 Display retracement values

  • The new "Show retracement levels?" option displays the retracement levels for each pattern found. You can see the exact values of XAB, ABC, and other pattern legs displayed directly below the pattern name. The same information is also displayed when you hover your mouse cursor over the label with the pattern name (no matter if the "Show retracement levels?" option is enabled or disable). This is useful when labels are hard to read because they are on top of each other.
  • Improved accessibility by adding options to change the color of the labels and text. If you don't like (or don't see well) the default black text on a red (sell pattern) or green (buy pattern) background, you can change those colors.
  • Updated default of "Depth of a zigzag pattern" from 8 to 10 (it's a better default value for any interval).

Here are all the retracement levels used for each pattern:
Gartley:
XAB: 0.618
ABC: 0.382, 0.5, 0.618, 0.786, 0.886
BCD: 1.13, 1.272, 1.414, 1.618
XAD: 0.786

Butterfly:
XAB: 0.786
ABC: 0.382, 0.5, 0.618, 0.786, 0.886
BCD: 1.618, 2.0, 2.24
XAD: 1.27

Bat:
XAB: 0.382, 0.5
ABC: 0.382, 0.5, 0.618, 0.786, 0.886
BCD: 1.618, 2.0, 2.24, 2.618
XAD: 0.886

Alternate Bat:
XAB: 0.382
ABC: 0.382, 0.5, 0.618, 0.786, 0.886
BCD: 2.0, 2.24, 2.618, 3.14, 3.618
XAD: 1.13

Crab:
XAB: 0.382, 0.5, 0.618
ABC: 0.382, 0.5, 0.618, 0.786, 0.886
BCD: 2.618, 3.14, 3.618
XAD: 1.618

Deep Crab:
XAB: 0.886
ABC: 0.382, 0.5, 0.618, 0.786, 0.886
BCD: 2.24, 2.618, 3.14, 3.618
XAD: 1.618

Cypher:
XAB: 0.382, 0.5, 0.618
ABC: 1.13, 1.272, 1.414
BCD: 1.272, 1.414, 1.618, 2.0
XAD: 0.786

Shark (we assume that Shark formation points are named X,A,B,C,D just like all the other formations, and not 0,X,A,B,C like in some literature):
ABC: 1.13, 1.272, 1.414, 1.618
BCD: 1.618, 2.0, 2.24
XAD: 0.886, 1.13
Release Notes: Version 1.3.1 Stability and performance improvements

The script should no longer throw the "Pine cannot determine the referencing length of a series" error, and the "Loop is too long (> 200 ms)" error should happen much less often.

You can find more information about our scripts at https://www.patternshunters.com/
Protected script
This script is published closed-source and you may use it freely. You can favorite it to use it on a chart. You cannot view or modify its source code.
Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?