TradingView
Trendoscope
31 Th07 2021 19:19

Multi Level Zigzag 

Microsoft CorporationNASDAQ

Mô tả

At first I thought of doing double zig zag. Once developed I thought it is not much effort to make it multi level zigzag. This script is not same as multi-zigzag indicator (link in the end). In multi zigzag indicator we use zigzag based on different length and each zigzag has no relation to each other. In this script however, each zigzags are related to each other. We cannot just derive Zigzag 4 without deriving Zigzag 3. (Though we can hide each of them individually)

The logic is simple.

Zigzag1: This is the basic zigzag plotted based on given length.
Zigzag2, Zigzag2, Zigzag3 : These are built based on lower level zigzags.

For example, Zigzag2 is built based on Zigzag1 pivots. For calculation, we just use N*2 number of Zigzag1 pivots to derive the next level. Similarly Zigzag2 will become input for Zigzag 3 and Zigzag3 will become input for Zigzag4

Input parameters allow you to chose upto 4 levels of zigzag along with zigzag line color and length. Max array lines also defines how many lines back you want to calculate the zigzag pivots and display then in the stats. Lowering this number will not reduce the number of lines - but, it will limit possibility of calculating higher level zigzags. Stats table just highlight which pivots are applicable for which outer level.

Application: Can be used in pattern recognization scripts to improve accuracy.

Disclaimer: This is not working in intraday charts. Nothing I could do at this point of time. Use it only for daily + timeframes.

Related scripts:

tradingview.com/script/6wTGMboG-Multi-ZigZag/

tradingview.com/script/Q7YifAAf-Multi-ZigZag-Harmonic-Patterns/

tradingview.com/script/PZaJujxB-Multi-ZigZag-EW-Impulse-V2/

Phát hành các Ghi chú

  • Added zigzag chain option. If chain is used, zigzags are based on previous levels. If chain is not used. All multi level zigzags are derived based on base level - Level1. But, lengths gets added up on each iteration.
  • Added waitForConfirmation flag for plotting next level pivots

Phát hành các Ghi chú

There was a small issue in zigzag calculation where single bar presented both pivot high and low. This has been corrected.

Phát hành các Ghi chú

Remove redundant vars

Phát hành các Ghi chú

Major changes
  • Added option to use external source or custom source instead of regular high/low for zigzag.
  • Memory optimization by deleting old elements of array.

Phát hành các Ghi chú

Minor corrections.

Phát hành các Ghi chú

Convert to pine5
Bình luận
FinTechKing
Hello sir, from which planet you came. Your work is awasome and you have broken all the barriers. Thanks sir .
deshmukhag
Excellent work sir..:) could you help me to add Up_color and dn_color in this script for L1 zig-zag lines? thank you so much in advance
Trendoscope
@deshmukhag, At present script color is based on zigzag color. Up color down color will confuse things as there are multiple zigzags. If you want to implement that, you need to change zigzagcolor in draw_zg_line. Instead of taking it as method parameter, you need to get zigzagdir using code

dir = array.get(zigzagpivotdirs, idx1) // need to pass this array (zigzagpivotdirs) in the method


Once you have direction. You can put color based on if dir < 0 or > 0
deshmukhag
@HeWhoMustNotBeNamed, Sir, I am using only one zigzag. Tried to implement the changes you suggested, but could not do it. Sorry, I am not good at programming. requesting your help to add the code you have suggested please. thank you so much for your support sir
by_otto
hello master. I would like to thank you for taking the time to share with us the work you have done for humanity without expecting anything in return. God bless you.
zxc991208
good
zxc991208
good
ShahZak
is this zig zag similar to Harmonic Elliot wave theory?
RAJritvik318
sir if you are in india i want to make you my teacher and want to touch your feet because you are a person who give us a vast knowlage and wonderful scripts . at zero cost . its my dream to meet you sir truly great sir , at last soory for my bad english and thanku sir .
Thêm nữa