PROTECTED SOURCE SCRIPT

Auto Harmonic Patterns - V2

Обновлено
Hello traders. After getting good response to my earlier Harmonic patterns scripts, decided to deep dive a bit and make it bit more interesting and detailed.

Before I explain further on the script, few important things to note:

The script is very intensive and may often timeout or give memory error. If that happens, just reload the script. It may not work on smaller timeframes due to same reason. At this point, we cannot do much about it.
This should not be considered as strategy - but as a tool to make your harmonic based trades. Options are available to set your entry, stop and target levels based on your trading methods.
If there is timeout - try reducing the scope by disabling few zigzags and reducing Max depth from the settings.
Script does not show historical patterns. It will only show patterns which are currently in trade. This is done to reduce errors due to number of lines and labels. To track past patterns, you can either replay previous bars or use stats table.
After lots of deliberation, this script is released as protected script instead of invite only. Use it well :)

OVERVIEW

This script combines earlier two scripts defined on harmonic patterns:

Multi-ZigZag-Harmonic-Patterns
Multi-Level-ZigZag-Harmonic-Patterns

Merging these two the present script allows up to 4 Zigzags to be used and each zigzag comes with one multi level Zigzag. Logic of deriving multi level zigzag is described here: Multi-Level-Zigzag

On top of that each combination scans last 11 pivots (Max Depth) with all permutation combinations to come up with better pattern recognition. So, the complexity of the scan is 8 * (MaxDepth-4)!/2

In order to speed up the execution, you can chose to enable only the zigzags you are looking to trade instead of allowing all 4. Multi level zigzags cannot be enabled/disabled separately at this point.

INPUT PARAMETERS

Target and Stops

Entry Ratio : Minimal retracement from AD or CD (whichever is max) to enter into order
Stop Ratio : Retracement or extension from AC or AD (whichever is max) to stop or invalidate the trade. Negative values mean that stops are placed beyond D away from A/C whereas positive valus mean stops are placed between A/C and D. Please note Stop Ratio should be lesser than Entry Ratio. Wider the better for longevity of trade.
Target Ratios: Different points where profits can be taken. This is not optimized for strategy or pattern. To be used as per individual trading method.
Trailing Start Stage: This tells after what stage to start trailing stop loss. Trail will be based on difference between past subsequent levels. For example, if instrument is trading beyond Target 4, trail distance will be target4-target3

Pattern detection settings

Error Percent : Error threshold to be allowed for pattern recognition
Max Depth : Number of last pivots to consider for scanning patterns with m X n permutation. Increased numbers show more patterns but also slows down the script and may even lead to timeout.
Wait For Confirmation : Pattern recognition only happens on confirmed zigzags. Stats will show higher success rates and lesser patterns if this option is selected. That is because, there will be lag in identifying the patterns as confirming zigzags takes few bars.
Ignore if Entry Crossed : Only effective when Wait For Confirmation is enabled. If price has gone beyond entry when pattern has formed, system will ignore the pattern and do not try to plot it on charts.

Stats and Display

Show Trade Stats, Open Trades Stat Position, Closed Trades Stat Position can be used to display trade statistics and set different positions for tables display
Show Targets : Display/Hide target and stop levels
Show XABCD : Display/Hide XABCD marking on patterns
Show Ratios : Display/Hide harmonic ratios used for pattern recognition

Zigzags ( 1 - 4 )

L1 Length is primary zigzag length.
L2 Length is for deriving multi level zigzag based on L1

Patterns

Allows enabling and disabling several patterns. List includes:

Classic Patterns
Gartley
Bat
Butterfly
Crab
Deep Crab
Cypher
Shark
NenStar

Anti Patterns
Anti NenStar
Anti Shark
Anti Cypher
Anti Shark
Anti Crab
Anti Butterfly
Anti Bat
Anti Gartley
Navarro 200

Comprehensive list of patterns are listed here: Complete List of Harmonic Pattern Ratios

TRADE STATISTICS

Open Trade Stats consists of following fields
Zigzag - Zigzag length and level 2 length
Status - Current status of the trade. This includes - Awaiting Entry, In Trade, Target<1-4> Reached
X, A, B, C, D - price levels of X, A, B, C, D
Entry, Stop and Target Levels - These are same as what is shown on chart for present trades but presented in tabular way for better readability in case there are more number of trades.

Rows will have green background on bullish trades and red background color for bearish trades. Bullish and bearish colors can be set in Generic Color input settings. Text Color will be same as Zigzag line color which can be set in settings.

Closed Trade Stats consists of following fields
Overridden - these are patterns which are formed but overridden by other pattern based on the same XABC but with different D with better risk reward. Pattern is overridden only if entry/stop is not reached
Failed - These are the patterns which are successfully formed. But, price failed to hit entry before hitting stop. Hence, these signals are not taken as trade.
Stopped - These are the signals where price successfully hit Entry. But, failed to reach any of the targets before hitting Stop or Trailing Stop (If Trail Start Stage is set to Entry)
Target(1-4) - These numbers imply number of trades which successfully hit the respective target level but failed to hit next target level (Except target 4 which is the last target level)

Close stats show numbers based on Bullish and Bearish signals generated. It also shows numbers based on the zigzag length and level 2 length.
Информация о релизе
Icing on the top.

Added built in alerts for
  • New harmonic pattern detection
  • Close of trade on existing pattern with target reached status
  • Whenever new target reached
Информация о релизе
Updated alert frequency to once per bar to avoid multiple alerts triggered together.
Информация о релизе
Few critical updates
  • Representing PRZ (Potential reversal zone as box. New patterns formed will not override if new D is within the box.
  • After lots of queries related to delay in pattern identification, Wait For Confirmation is set to false by default to generate pattern without lag.
  • Pattern label moved to show in PRZ box
  • We have set default target levels for each pattern. So, user input will only be effective if Override Default Targets is selected.
Информация о релизе
Applied latest zigzag fix
Информация о релизе
  • Fixed error target appearing below entry and unordered targets
  • Stats table made smaller.
Информация о релизе
Some key fixes related to zigzag and memory optimization

There is a overlapping pattern issue which comes up on adjacent candles. (As in the chart) Will try to fix it soon.
Информация о релизе
Remove debugger code
Информация о релизе
Convert to pine 5
Информация о релизе
Minor bugfixes
Информация о релизе
Fixed the pine error which got introduced in latest update
Информация о релизе
Update signature and tags
Информация о релизе
Fixed a bug user highlighted.
Информация о релизе
One more fix :)
Информация о релизе
Deprecated. Please use tradingview.com/v/3IrFGqVZ/
Информация о релизе
Removed the deprecated banner as per moderator instructions. The script is deprecated. Meaning, We will not be making any new major modifications to this script. Having said that it is fully functional and can be used. If there is any defect, we are happy to fix it in order to maintain the usability of the script.

But, if you are looking for improved implementations, please use Auto Harmonic Pattern Extreme instead of this implementation.
Chart patternsHarmonic Patternshewhomustnotbenamedtrendoscope

Скрипт с защищённым кодом

Этот скрипт опубликован с закрытым исходным кодом, вы можете свободно им пользоваться. Можно добавить его в избранное и использовать на графике. Вы не можете просматривать или менять его исходный код.

Хотите использовать этот скрипт на графике?


Мои профили:

Отказ от ответственности