TradingView
vnhilton
Mar 31, 2024 7:35 PM

ZigZag With ATR Filter [vnhilton] 

Bitcoin / TetherUSBinance

Description

(OVERVIEW)
The typical ZigZag indicator, which connects pivot points (see TradingView's Help Center regarding their indicator Pivot Points High Low, for an in depth explanation on how they are calculated) with lines, except instead of a percentage threshold, it uses ATR which adjusts for volatility of the ticker you are viewing. The ZigZag indicator can therefore be used to help visualise price legs and trends on a usually noisy looking chart.

(FEATURES)
- Toggles for pivot point label contents such as the value, the trend, or nothing at all.
- ATR and pivot point periods.
- ATR multiplier minimum threshold to plot pivots and draw lines only when this threshold is met (helps eliminate small, perhaps insignificant price movements, to have a better focus on the overall trend).
- Show the last 2 to 499 ZigZag lines.
- Uptrend, downtrend and range colors for high and low pivot labels, text labels and lines, for both confirmed and real-time plots.
- Label size, and label styles for the high and low pivots.
- Customisable width and styles (Arrow Right, Dashed, Dotted, Solid) for the ZigZag line.


In the main chart picture, labels show both the pivot point value and the trend at that point. In the picture above, on the left shows only the pivot point value, the right shows only the trend.


Picture above shows just the label with 0 contents. Also notice the last recent line being blue instead of green. This is because the current bar hasn't finished so this line is currently live and not confirmed, so is subject to change. Keep in mind even if a pivot point is confirmed, it can be updated by a subsequent higher high/lower low.


Left chart shows a minimum ATR threshold multiplier of 1x; Right chart has 2x ATR minimum threshold. Notice the left chart highlights more price legs as more price legs satisfy a less strict threshold.

Release Notes

- Correctly formatted pivot price (using format.mintick)

Release Notes

- Fixed issue of new pivot high/low occurring right after a pivot high/low (plotted pivots should only alternate between high and low). Solution was to add additional condition making sure pivot highs were higher than last low pivot, and pivot lows lower than last high pivot. Also changed conditional statements to using strings instead of high/low built in variables.

Release Notes

- Changed pivot point identifier logic (now allows bar highs/lows to equal each other). Done because moves with double/triple/etc. tops/bottoms were ignored.

Release Notes

- Decreased max zig zag lines by 1 (498 max) to make room for the potential line.

(NEW FEATURE)
- Added the potential line. Plots a line from the last pivot point to the current bar as a potential ZigZag line. When the current close is above/level/below the last pivot, the line right point attaches to the current high/close/low. The line left point attaches to the last pivot if there is only 1 pivot, or the line is sloping up/down and the last pivot is a low/high pivot, or the line is level. Else, it attaches to the 2nd last pivot.

- Customisable line width and style
- 3 line colors for when the current close is above/level/below the last pivot


Potential up line from the 2nd last pivot, which is a pivot low.


Potential down line from the last pivot, which is a pivot high.





Release Notes

- Adjusted default ATR period to 20

(NEW FEATURES)
- Added ZigZag size label text
- Added ZigZag time label text
- Added ZigZag volume label text (with imperfect solution, so if encountering error, please use lower pivot point length or disable volume entirely (apologies))

Release Notes

- Made label formatting neater based on differing toggle options.

Release Notes

- Reduced max lines to 497

(NEW FEATURE)
- Potential line label
_____________________________
(I will add second order pivot ZigZag in the future when I am free. The code will also be completely revamped to be more robust, efficient and clean, written with scalability in mind. Challenges for this future update are: working out the garbage logic for 1st and 2nd order ZigZag lines (as there can only be maximum 500 lines for 1 indicator), adapting the code so that it can be used for both calculating 1st and 2nd order ZigZag lines, and tracking volume for each ZigZag line)

Release Notes

- Fixed potential line label values
Comments
Indyan
Great work, can u please make structure mapping as per this chart image


if this is possible then make an option to select your default (current) label with this Image kind label
You can check "Higher-High-Lower-Low-Live" by our wizard LonesomeTheBlue which is based on given chart image.

thanks
vnhilton
@Indyan, hi Indyan, other than LTB’s indicator, could you please point me to another source (preferably a webpage source) where ZigZag is labelled like this? I can see the idea but I would need further clarification on more complex examples.

In the last scenario on the chart image you provided, the trend goes as follows:
HH-HL, HH-HL, HH-Low (instead of HH-LL) which turns to HH-HL if the following pivot is a HH. Would that not mean the final trend structure is as follows: HH-HL, HH-HL, HH-HL, HH, where the 2nd last HL is actually higher than the last HL, which doesn’t make sense unless you’re asking to ignore the 2nd last HL and the HH, which would mean you lose out information on the 2nd last legs which is not ideal when analysing accelerating moves.

Please see my code (it’s open source), particularly the TrendColors function at Line 155 on all the trend combinations I used. I would again need to see a lot more complex scenarios as LTB’s script is closed source, please. Thanks
Indyan
@vnhilton, Sent u message, posting link is not allowed
ukmpits
@vnhilton Sir, Is there any future Improvement? Thanks mate
vnhilton
@ukmpits, hi ukmpits, yes I am planning on adding more data to the labels such as age of leg (number of bars between pivots), volume accumulated and size of up/down leg relative to prior up/down leg. I am also considering 2nd order pivots. Let me know if you have any suggestions. Thanks
Indyan
@vnhilton, ye 2 or 3 zigzag with different values would be really great with and option of divergence with macd 4c. it will help Elliott wave traders as well as price action traders . thanks
vnhilton
@Indyan, I am not aware of these concepts and not so familiar with Elliot waves. I would need a lot of convincing on their efficacy as from what I have seen, the rules surrounding Elliot waves seem overfitty.
Indyan
@vnhilton, This market structure is based on RTM (Read the market) which is one of the finest and expensive concept/course in trading community
Ew dont need these labeling but with multiple zizzag we can understand the degrees of waves in one go
ukmpits
@vnhilton, Sir, sorry if i suggest out of topic..considering support resistance level and price action on forex/stock trading.. would you like to add this feature: Swing Start,rebound trade/lower low/cl point,obv, breakout,check/manage risk,testing supply demand,if break level,swing start on upper resistance wait for accumulation,profit taking, supply zone,etc
vnhilton
@ukmpits, hey ukmpits, I am not familiar with these concepts - could you please point me to some sources? Thank you
More