AB=CD Patterns

Script that detects "AB=CD" patterns on the chart. Unlike other scripts, it doesn't put a bunch of unnecessary lines and mysterious arrows on the chart. It clearly indicates where a pattern can be identified and labels it with either a "buy" or "sell" label to show if it's a bearish or bullish pattern.

  • You can check an unlimited number of the high/low points. Use the "Number of points to check" option to configure how many points to check. Remember that checking for too many points in the past will make this script slower (or it can even timeout and cause a 'Script Error').
  • You can configure the error margin using the "Error tolerance (in %)" configuration option. It defines how much the detected AB=CD pattern can differ from the "ideal" pattern. With a 5% error tolerance, if the "ideal" retracement is equal to 0.618, we accept a retracement between 0.5871 and 0.6489.
  • You can change how many previous candles are considered when checking for the high/low points by changing the "Depth of a ZigZag pattern" option. If you choose a high number, there will be fewer points to check, and the script will be faster. If you choose a low number, the script will be slower, but it will check more points. To see the high/low points on the chart, enable the "Draw ZigZag" option.
  • You can change the lines' width using the "ZigZag line width" and "Formation line width". It's a purely cosmetic option, and it doesn't change how the script works.

It's currently using the 0.382 to 0.886 retracement levels for the ABC leg and 1.13 to 2.618 retracement levels for the BCD leg. In the future, there will be a configuration option to use the "ideal" ratio proposed by Scott Carney (more strict than the current one).

Release Notes:
Version 1.1

The first update adds the "Strict" ratio option for those of you who want to use a more strict variant for the retracement levels.

  • Added option to select between "Strict" or "Standard" ratios. "Standard" means that we check 0.382, 0.5, 0.618, 0.786 and 0.886 retracement levels for point C (in the ABC leg) and 1.13, 1.272, 1.414, 1.618, 2.0, 2.24 and 2.618 for point D (in the BCD leg). "Strict" means that only check 0.618 and 0.786 for point C and 1.272 and 1.618 for point D.
  • Added "Move charts" option. When you have many formations on the chart, and they share the same points, only the topmost line is visible. With the "Move Charts" option enabled (it's disabled by default), we move all those points up/down a bit to make all the lines nicely visible and easy to follow.
Release Notes:
Version 1.2 Alerts, more configuration options and stability improvements

  • Alerts - you can now add alerts to get a notification when a new AB=CD pattern appears.
  • Configurable "Move charts" option - you can select by how many percent you want to move charts that are hiding each other. This is useful when you use a small interval where moving charts by 1% of a total price will move them too much.
  • Indicator is much more stable for smaller intervals. Before, when you used a short interval (seconds or minutes), the script crashed almost immediately after the first few bars. Now it should work much better. However, it might still crash from time to time - that's when it's referencing points from the past that TradingView discards when new bars are added to the chart. If this happens, refresh the page or hide and show the indicator again (also, decrease the "Number of points to check" for better performance). If you are using 1H or a larger interval, you probably won't see this problem at all.
Release Notes:
Version 1.3 Configurable retracement levels, display retracement values and more styling options

  • Replaced the "Standard" and "Strict" ratio options with fully configurable retracement levels. You can select which exact values you want to use. Retracement 3.14 for the BCD leg is disabled by default, and all the other levels described in the "Harmonic Trading Volume 1" by Scott Carney book are enabled.
  • The new "Show retracement levels?" option displays the retracement levels when a pattern is found. You can see the exact values of ABC and BCD retracements 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)
  • You can select whether you want to display only the Up or Down patterns (by default, both are enabled).
  • 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.

You can find more information about our scripts at
Protected script
This script is published closed-source but you may use it freely. You can favorite it to use it on a chart. You cannot view or modify its source code.

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?