TradingView
Trendoscope
Jul 3, 2021 6:44 AM

ZigZag (Using Line Array) 

NASDAQ 100 IndexNASDAQ

Description

This is standard zigzag indicator. I just coded them using lines array feature of pine - so that it can be done in least number of lines of code.

Few possible improvements:

  • Use label array to mark HH, HL, LH and LL
  • Add standard deviation check

Release Notes

Added updates mentioned in the description.

Release Notes

Corrected HL and LH labels

Release Notes

Added ratios display.

Release Notes

  • Previously, using pivotHigh and pivotLow on every bar for last 10 periods caused some inconsistencies in plotting zigzag. Hence, switched to points based calculation. However, zigzags are still created via lines array
  • Fixed empty label issue

Release Notes

Solved array index out of bounds issue

Release Notes

Adding option to apply zigzag on different source such as RSI. This enables plotting zigzag and ratios on RSI - which can be used for finding divergence.

Release Notes

  • Corrected minor logical error.
  • Removed DeviationThreshold as it was leading to wrong calculation
Comments
RozaniGhani-RG
Trendoscope
@RozaniGhani-RG, Thanks. It was bit of earlier implementation of Zigzag. I do not use this method anymore. Calculating the coordinates and drawing separately is a better approach.
Daniel-kay
Hi @HeWhoMustNotBeNamed thank you for sharing!
May I ask you why others parameters like deviation and backstep cannot be set?
The default are the more used ones? Deviation: 5 and Backstep: 3?
Searchingforall
Hi! Is there a way that it can display retracements from 50% to 78% max and filter all the other? Great work!
TAEquint
can you guide ???
i wanted to control how much lines and labels i wants on chart !!!
Henk_Idiogenes
Thanks for contributing the indicator and making it open source. I am interested in finding the values of the turning points from your script. Could you please be so kind as to explain how to do so? Thanks in advance.
Trendoscope
@hindiogine, You cannot find it. That's not how the zigzag works. Last pivot always repaints. Zigzag is mainly used for identifying the patterns rather than exact turning points.
Henk_Idiogenes
@Trendoscope, thanks for your reply. I am interested in finding the turning points to determine the presence of harmonic patterns. I understand that the last leg could move to a different point because the price of the last candle may cause that. However, I can live with that.
Trendoscope
@hindiogine, search for zigzag based libraries in my script list - that will give you the required outcome. However, you need to work with them to understand what you are getting and how to use them for your logic.
NEKSUS_
Thank you a Lot!!
Can you update skript? ( The function 'add_to_zigzag' should be called on each calculation for consistency. It is recommended to extract the call from this scope.)
More