Auto Harmonic Pattern - UltimateX [Trendoscope]

IMPORTANT NOTE: (Read this before looking at any other thing on this indicator)

This indicator is created to supersede existing Auto-Harmonic-Pattern-Ultimate-Trendoscope invite only script. The script deviates a lot from the original Auto Harmonic Patterns Ultimate script in terms of number of available patterns, trading type and few other things. Hence, instead of updating the existing script, we have just decided to release as new script. Few FAQs in this regard are as below

What it means for users of AHPU and new users?
▶ Subscription of this script is not sold separately, but will be offered along with existing AHPU script. Meaning, there will be single subscription for both scripts together.
▶ All existing subscribers of AHPU will also get access to this script for the duration of their subscription term. Will start adding access to users starting from lifetime subscribers first.
▶ Any new subscriptions to AHPU will also get access to both the scripts together. We will eventually look to phase out existing AHPU once users are accustomed to new script and any possible bugs are resolved.
▶ Any trial requests will also get access to both scripts. You can request trial even if you have recently requested trial for AHPU.

Why did we create new script instead of updating the existing one?
▶ As mentioned before, this script deviates a lot from the original AHPU. Hence, it is released as new version to make sure smoother transition of users. If anyone is not comfortable using the new version, they can continue using the existing AHPU script until things settle down.
▶ Since the script is new implementation, it may also have initial bugs. It will help us resolve it in more streamlined way.

What are the main differences between these scripts?
▶ Uses single zigzag instead of multi as algorithm is further improved to detect almost everything using single zigzag .
▶ More number of patterns added. But, new patterns are disabled by default as some of them have very wide PRZ. Users can enable it via settings.
▶ Trading type with trailing entry - With wide PRZs, we also had to implement different method for calculating entry/stop. This is explained later in the script.
▶ Matrix implementation and enhanced stats - Entire implementation is redesigned to use matrix data structure instead of arrays. This allows lots of possibilities including enhanced closed trade stats.
Support/Resistance widget is removed as it is proving to be bit of overhead. Users can make use of Support Resistance widget script which is a free to use script instead.

Let's get to the details of indicator now. As with any other harmonic pattern based script, this is combined work of myself and @cryptoarch_ and we both co-own the rights to this work.

🎲 Indicator Components

🎯 Patterns Covered
● Classic Patterns
● Anti/Alternate Patterns
● Non-Standard Patterns (Disabled by default)

Below is a quick snapshot of indicator components.

Now, lets look at some of the individual components:

🎯 Open trade stats helps recognise trades in motion.

Apart from regular stats, it also contain different types of risk reward ratios.

  • Regular RR : RR calculated from entry to reach target with initial stop for risk consideration
  • Trailing RR : This is RR calculated for price to reach from one target to next target considering trailing stop for calculating risk
  • Live RR : This is calculated based on current price as entry and with given targets and stop levels. Live RR will be blank for targets which are already reached.

Targets are calculated only when entry is made. Hence, target details are not shown for patterns where it is still awaiting entry.

🎯 Closed trade stats helps understand historical performance of patterns.

By default closed stats are displayed in Compact mode. Which means, only total stats are shown. But, users can change this to show detailed stats via settings. Detailed stats take up entire screen most of the time. So, keep them only if it is required.

Closed stats present average Risk Reward, Trailing Risk Reward, Average Win Rate, and Average Trailing Win Rate for all the possible levels. As discussed before.

  • Regular RR : RR calculated from entry to reach target with initial stop for risk consideration
  • Trailing RR : This is RR calculated for price to reach from one target to next target considering trailing stop for calculating risk
  • Win Rate : Simple win rate calculation based on number of patterns reached target and number of valid patterns.
  • Trailing Win Rate : This is win rate calculated based on previous target to current target.

For example, if there are 48 valid patterns and out of which 24 patterns reach target1 and 12 patterns out of 24 reach target 2
Target1 WR : 50% (24/48)
Target1 TWR : Not applicable as there is no target before Target1
Target2 WR : 25% (12/48)
Target2 TWR : 50% (12/24)

🎲 Settings

Tooltips are provided to help with each and every settings. And they are as below.

🎲 Fully Customisable Alerts - Placeholders

Alerts are created via alert() method of pine. Hence, users will not see message box for alert template on alert widget.

Instead alerts widget look something like this:

To overcome this issue, script provides alert template placeholders as part of settings. In settings, you can already see Alert section where you can enable/disable alerts for different events.

▶ New Pattern Detection
▶ Entry Reached
▶ Target1-4 Reached
▶ Stop price reached
▶ Trade Complete - either by stop or reaching target 4

You can use following placeholders in the given text boxes to create your own alert template.

🎯 Common placeholders which are applicable for all alerts
{type} - Alert Type
- New Harmonic Pattern
- Harmonic Pattern Status Update
- Harmonic Pattern Trade Closure
{id} - Pattern Id. This is not fully unique id. But, this will be unique for all open trades. Once trade is closed, Ids are reused whenever feasible.
{ticker} - Ticker information
{timeframe} - Timeframe information
{price} - Current close price
{patterns} - Possible patterns for the projections or PRZ.
{direction} - Trade direction - Bullish or bearish
{entry} - Calculated entry for pattern
{stop} - Calculated stop for pattern
{tstop} - Trailing stop for the pattern in trade
{target1} - Target1 for pattern in trade
{target2} - Target2 for pattern in trade
{target3} - Target3 for pattern in trade
{target4} - Target4 for pattern in trade

🎯 There are few specific placeholders, which are applicable for some alert types.
Harmonic Pattern Status Update
{status} - Status of the Pattern in trade
{laststatus} - Previous status of the Pattern in trade

Harmonic Pattern Trade Closure
{result} - Trade result upon closure
Release Notes: Update 1.1

  • Removed failed patterns from closed stats as this causing confusion. You can still get failed patterns details by looking at the total which contains two numbers. /. Difference is the number of failed patterns count.
  • Removed Stopped patterns from closed stats as this number can be easily derived from Win rate of target1. Stopped Percent = 100 - Target1 Win Rate
Release Notes: No change in version. Just updated chart :)
Release Notes: Update Ux1.2

Added option for selective display of closed stats where it shows totals and detailed stats only for the patterns which are open.

Release Notes: Update Ux1.3

Updated available options for Base - which is used for calculating target levels. But, the default value is still kept as min.

Fixed a minor bug in trailing.
Release Notes: Update Ux1.4

Added an option to use confirmed bar. This means, the current bar where high/low can change will not be used for any calculation. This is done to give an option for those who want to use alerts.

  • When using real time bar, signal can waver and may lead to pattern forming and moving out of range. Hence, you may get an alert on new pattern, but, you may not see that on chart because it has gone out of range and pattern is deleted. It does not impact stats much. But, it does indeed give some troubles for those who want to use alerts. Using confirmed bar reduces this issue.

  • Alerts are delayed by one bar. Which also mean that you can miss potential entry. However, it becomes easy for those who want to trade by setting stop limit orders as you would know the stop limit entry prices before hand.
Release Notes: Update Ux1.5

Minor bug fixes on the previously released feature of 'Use confirmed bars'
Release Notes: Update Ux1.6

Fix recurring alert issue.
Release Notes: Update Ux1.7

Added options to filter trades by supertrend or moving average. You can see the relevant options in settings. They are disabled by default.

Impact of applying the settings can be studied in closed trade stats.
Release Notes: Update Ux1.8

This version mainly intends to fix the issue came up against alerts. It looks like alert timed out due to having too many settings. Due to this, had to remove several less used settings to make it work.

Hence, I have removed following settings:
  • Open Stat Options to show RR/Trailing and Current RR/XABCD - RR options are hardcoded to true whereas XABCD option is hardcoded to false
  • Bullish/Bearish color options removed and are hardcoded to green and red
  • Start/End Range option is removed. Script runs for maximum possible range

Will try to reintroduce them if required when alert issues are resolved.
Release Notes: Major Update Ux1.9

  • Using lightweight private libraries to increase performance. Private Libraries were not allowed earlier to be used in invite only scripts. Thanks to tradingview's recent updates. It is very much possible now. Due to this, libraries used can be restricted to minimal required in order to improve load time and avoid errors.
  • Removed confirmed Bar option as it was creating some confusion among the users.
  • Added option to Ignore patterns if entry already reached on the D bar. This can help those who prefer to trade on confirmed bars. This does not work in same way as now removed confirmed bar option. But, it is targeted for users with similar trading style.
  • Added two more placeholders for alert template. {pivots} and {targets} which gets replaced with array of pivots and targets respectively
  • Added a new type of alert called summary alert which is disabled by default. When enabled, alerts are triggered once per bar close containing the summary of all patterns in trade.
  • Limiting the backtest range is introduced back. But instead of providing date based filter, providing bars based filter. This is more adoptable to different timeframes as available backtest timeframes are usually from 20k to 30k

Apart from the efforts have been done to increase the accuracy and consistency of alerts. Thanks to few users (@boost_inc, @leoebbert, @satoribr) who have been thoroughly testing this and coming with more details on shortcomings.
Release Notes: Update Ux2.0

  • Pattern size and age (in terms of bars) is shown in open trade stats
  • Average Pattern size is added to the total column of closed stats.
  • Tooltips are added to closed stats table. Hover on any cell to see more information.
  • Options added not to display additional details such as risk reward, percentage etc. on open stats.
  • Added option to filter patterns by size (number of bars)
Release Notes: Update Ux2.1

One last update before boarding my flight.

  • Pattern size data is added for individual patterns and each targets as well. Can see them when percentage mode is off.
  • Apart from tracking entry, the script now also tracks how many of the patterns retest before reaching targets. This stat is helpful for traders who want to play safe by waiting for entry signal and then place limit order. Again, retest data is added to both open stats table and for all pattern and target breakdown of closed stats.
  • Tooltips to provide more info about the stats shown in closed stats table. Just hover on the tables to understand more about the data being presented.
Release Notes: Update U2.2

Added option to make use of recursive zigzag algorithm. Also moved some of the logic to private libraries to support faster execution.
Release Notes: Update 2.3

Quick fix of runtime error on higher timeframes.
Release Notes: Update Ux2.4

Few bugfixes
  • Fix highlighting issue
  • Fix issue related to separator in pattern names
Release Notes: Update Ux2.5

Updated library version for zigzag
Release Notes: Update Ux2.6

  • Added pattern size percentage filter for filter options
  • Added option to suppress updates on D bar
  • Fixed alert bug related to individual targets
Release Notes:
  • Fixed filter related issues for rZigzag method
  • Removed 'Suppress Alerts on D Bar' option as it created some other issues in real time alerts.
  • Removed varip based variables to track alerts as it was causing delays
Release Notes: Update Ux2.8

  • Fix few user reported issues and minor bug related to D bar repainting.
  • Removed Supertrend and Moving average based trend filters. (These can be added as external input now)
  • Added option to include an external input to filter trades. This means, you can build your own custom trend based scripts and use it with AHPUx to filter trades. Will also try to provide few sample filters in coming days.
  • Converted alert template from string to text area input to enhance visibility and ease of use.

Release Notes: Update Ux2.9

Enhanced External filter conditions also to allow bi-directional trades. With this new format of the external condition is:

  • 1 : Long Only
  • -1 : Short Only
  • 0 : No trades allowed
  • 2 : Allow both directions
Release Notes: Update Ux3.0

Minor correction on default alert template
Release Notes: Update Ux3.1

Few bug fixes related to trailing and delayed pattern recognition.
Release Notes: Major Update Ux3.2

  • Option added to disable trail entry. This is not recommended to disable trail entry. This option is added on demand from specific users.
  • Making use of lower timeframe data to find intra-bar fluctuations. Due to lack of tick data, it is tricky sometime to identify on a volatile bar whether entry/targets reached first or trailing stop. Even though we still do not have tick data, we are making use of lower timeframe OHLC values to find out this information. Which ultimately improves the accuracy of stats on historical bars.
Release Notes: Update Ux3.3

Minor update with respect to LTF logic. Also, since LTF data is not available for less than 1m timeframe, it is not advisable to use the indicator for less than 5m timeframe to allow sufficient calculation based on LTF candles.
Release Notes: Update Ux3.4

  • Added new built in filters based on OBV. Direction of OBV is also presented in open stats table and on chart (next to ratios)
  • Label positions for targets and stops are changed to appear above and below the line based on direction to make it more intuitive.
  • Changing the size of XABCD label text will also change the size of target labels. (Done based on request)

Few screenshots to showcase the changes made

New OBC filters:

OBV directions on chart and stats table:
Release Notes: Update Ux3.5

Apologies, had to revert the OBV update as it causes issues for those who do not have volume data.
Release Notes: Update 3.6

  • Updated library references
  • Removed redundant obv related settings
Release Notes: Major Update Ux3.7

Added back option to "Use Only Confirmed Bars" for pattern calculation - this will help better control of repaints which happen when using real time bars for calculation. Having said that, this also poses risk of missing out when the reversal is extreme. In order to handle that, have introduced few more measures:

  • When using confirmed bars, all the patterns which close outside PRZ box on the same bar are not considered and ignored. This means, we may not see lots of valid patterns which start with too volatile bars.
  • Default values of entry is increased to 30% from 10 so that volatile bars do not easily go beyond the PRZ box. Stop percent is reduced to default 0 for maintaining better risk reward and immediate recognition of pattern failure. This can be altered to 25/5 or 20/10 as well.
  • With increased entry percent, have also updated default target levels to higher values. While doing this deep care is taken to preserve the risk rewards and win ratios.
Release Notes: Update Ux3.8

Minor fixes and made Entry and Stop percent float to accommodate fractions

Invite-only script

Access to this script is restricted to users authorized by the author and usually requires payment. You can add it to your favorites, but you will only be able to use it after requesting permission and obtaining it from its author. Contact HeWhoMustNotBeNamed for more information, or follow the author's instructions below.

TradingView does not suggest paying for a script and using it unless you 100% trust its author and understand how the script works. In many cases you can find a good open-source alternative for free in our Community Scripts.


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.

Author's instructions

For purchase or trial, please visit https://s.trendoscope.au

Want to use this script on a chart?

Warning: please read before requesting access.