PROTECTED SOURCE SCRIPT
Updated Auto Harmonic Patterns

This is my first attempt on plotting harmonic patterns based on zigzag. Initial version is still primitive and might need lot of time to mature into more formidable one. Will try to explain entire logic in the description. Please feel free to correct me if my understanding of any pattern and underlying logic is incorrect.
In the initial version,
Logical ratios of patterns are coded as below:
Notations:
ABCD Classic
AB=CD
ABCD Extension
Gartley
Crab
Deep Crab
Bat
Butterfly
Shark
Cypher
Three Drives
5-0
In the initial version,
- Only immediate high lows of pivots are considered for calculation of patterns.
- In case of ABCD Types, only one is shown at a time. Hence, disabling certain ABCD pattern types may result in different numbers.
- Logic for double top/bottom is taken from previous script - Double top/bottom Ultimate. Though logic of confirmation and invalidation is not included
- All other patterns which involve 4+ lines can coexist and often shown together.
- Smaller timeframes may give error due to some pine limitations.
- Error percent parameter is used for allowing minor deviation from the standard ratios.
Logical ratios of patterns are coded as below:
Notations:
- Lines XABCD forms the pattern in all cases. (OXABCD in case of Three drives)
- abc = BC retacement of AB, xab = AB retracement of XA and so on
ABCD Classic
- 0.618 <= abc <= 0.786
- 1.272 <= bcd <= 1.618
AB=CD
- Price difference between AB and CD are equal
- Time difference between AB and CD are equal
ABCD Extension
- 0.618 <= abc <= 0.786
- 1.272 <= AD/BC (price) <= 1.618
Gartley
- xab = 0.618
- 0.382 <= abc <= 0.886
- 1.272 <= bcd <= 1.618 OR xad = 0.786
Crab
- 0.382 <= xab <= 0.618
- 0.382 <= abc <= 0.886
- 2.24 <= bcd <= 3.618 OR xad = 1.618
Deep Crab
- xab = 0.886
- 0.382 <= abc <= 0.886
- 2.0 <= bcd <= 3.618 OR xad = 1.618
Bat
- 0.382 <= xab <= 0.50
- 0.382 <= abc <= 0.886
- 1.618 <= bcd <= 2.618 OR xad = 0.886
Butterfly
- xab = 0.786
- 0.382 <= abc <= 0.886
- 1.618 <= bcd <= 2.618 OR 1.272 <= xad <= 2.618
Shark
- xab = 0.786
- 1.13 <= abc <= 1.618
- 1.618 <= bcd <= 2.24 OR 0.886 <= xad <= 1.13
Cypher
- 0.382 <= xab <= 0.618
- 1.13 <= abc <= 1.414
- 1.272 <= bcd <= 2.0 OR xad = 0.786
Three Drives
- oxa = 0.618
- 1.27 <= xab <= 1.618
- abc = 0.618
- 1.27 <= bcd <= 1.618
5-0
- 1.13 <= xab <= 1.618
- 1.618 <= abc <= 2.24
- bcd = 0.5
Release Notes
- Removed deviation threshold and disable stats on load. (Can be enabled in settings)
- Default length is set to 5
Release Notes
Convert to pine 5Release Notes
Update tagsProtected script
This script is published as closed-source. However, you can use it freely and without any limitations – learn more here.
Trial - trendoscope.io/trial
Subscribe - trendoscope.io/pricing
Blog - docs.trendoscope.io
Subscribe - trendoscope.io/pricing
Blog - docs.trendoscope.io
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.
Protected script
This script is published as closed-source. However, you can use it freely and without any limitations – learn more here.
Trial - trendoscope.io/trial
Subscribe - trendoscope.io/pricing
Blog - docs.trendoscope.io
Subscribe - trendoscope.io/pricing
Blog - docs.trendoscope.io
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.