TradingView
brettkind
2023年12月12日下午5點15分

Volatility ZigZag 

Snowflake Inc.NYSE

描述

It calculates and plots zigzag lines based on volatility and price movements. It has various inputs for customization, allowing you to adjust parameters like source data, length, deviation, line styling, and labeling options.

The indicator identifies pivot points in the price movement, drawing lines between these pivots based on the deviation from certain price levels or volatility measures.


The script labels various data points at the ZigZag pivot points on the chart. These labels provide information about different aspects of the price movement and volume around these pivot points. Here's a breakdown of what gets labeled:

Price Change: Indicates the absolute and average percentage change between the two pivot points. It displays the absolute or relative change in price as a percentage. Additionally, the average absolute price increase or the average rate of increase can also be labeled.
Volume: Shows the total volume and average volume between the two pivot points.
Number of Bars: Indicates the number of bars between the current and the last pivot point.
Reversal Price: Displays the price of the reversal point (the previous pivot).

發布通知

The labeling of the extended ZigZag line is new. Additionally, there is an alert function available.
The design and setting of the ZigZag label annotation have been revised.
Furthermore, the calculation is exported from a library called "Volatility_ZigZag_Library."

發布通知

The Volatility ZigZag Indicator is an advanced tool developed in Pine Script to identify key pivot points in price movements and draw ZigZag lines based on volatility and price changes. Unlike the traditional ZigZag indicator, which relies on fixed deviations, this indicator utilizes various volatility measures such as standard deviation, True Range, and Average True Range to dynamically determine more precise pivot points. This indicator offers a variety of customization options, allowing traders to better understand market structure through the lens of volatility and price movements, enabling them to adjust their trading strategies accordingly.

Key Features:
ZigZag Lines: The indicator draws lines between pivot points defined by significant price changes or volatility measures.
Customizable Parameters: Users can adjust parameters such as data source, length, deviation, line style, and labeling options.
Volatility-Based Pivot Points: Pivot points are calculated based on standard deviation, true range, average true range, and a selectable-user-parameter minimum deviation.
Labels and Annotations: The indicator labels pivot points with information on price changes, volume, and the number of bars between pivot points.
Notification Function: There is an integrated alert function that can trigger notifications when new pivot points are formed.

Labeled Data Points:
Price Change: Indicates the absolute and average percentage change between two pivot points. The geometric mean is used for average percentage change because it is better suited for aggregating percentage changes across different periods. Price Change values indicate the magnitude of price movements between pivot points. Higher values suggest more significant price changes, while lower values indicate smaller fluctuations.
Volume: Shows the total and average volume between two pivot points. Interpret within the context of market liquidity and trading activity to gauge the strength of price movements.
Number of Bars: Indicates the number of bars between the current and the last pivot point. Represents the duration of price movements between the current and the last pivot point. Interpret cautiously, considering the pace of market shifts and the significance of timing in trend analysis.
Reversal Price: Displays the price of the reversal point (previous pivot). Displays the price of the previous pivot, providing insight into potential trend reversals.

Standard Deviation and Volatility Measures:
Standard Deviation: A statistical measure that describes the dispersion of price values around the mean. It helps quantify the price volatility.
True Range (TR): The difference between the highest and lowest price of a period, including gaps in the price movement.
Average True Range (ATR): A moving average of the True Range, representing the average volatility over a specified period.
The Deviation H-Line in the Volatility ZigZag indicator dynamically adjusts based on whether the last pivot point was a high or low. When the price crosses this line, a new ZigZag pivot point is signaled, potentially indicating a trend reversal.

Calculation of Pivot Points:
A pivot point is established when the price exceeds a predefined deviation threshold. This deviation is defined as a dynamic value (volatility) or fixed amount based on deviation. If the trend moves sufficiently in the opposite direction and the price crosses the certain threshold, a new pivot point is marked.
Pivot points can be high or low points in the price movement.

Parameter and Data Source
Typically, high and/or low values are used for price data.
• Standard Deviation Calculation: Based on the default source, usually the closing price, or another selected source.
• True Range (TR): The difference between the highest and lowest price of a period, including gaps in the price movement (if high/low source is selected).
• Average True Range (ATR): A moving average of the True Range, representing the average volatility over a specified period (if high/low source is selected).
Length: Determines the number of bars considered for calculations, especially for standard deviation or Average True Range.
Minimum Deviation: Optional setting to establish a minimum deviation for ZigZag lines.
Standard Deviation Factor: Adjustable parameter for the standard deviation.

Notice
The Volatility ZigZag indicator cannot identify future levels because it relies on historical price data and volatility measures to determine pivot points. It reacts only after sufficient price movements have occurred that exceed a predetermined deviation. As a result, pivot points and corresponding ZigZag lines can only be determined retrospectively, after the necessary price changes have already happened. This backward-looking approach makes it impossible to predict future price movements or pivot points.
This is a Pine Script indicator for the public library "Volatility_ZigZag_Library" by me brettkind.

New
The "◯" points have been repositioned to the same Y-coordinate as “⦿”, but the X-coordinate corresponds to the point where the condition for a new ZigZag is true.
The ZigZag label text-size is adjustable from “tiny” to “huge” or “auto”.
評論
RozaniGhani-RG
brettkind
@RozaniGhani-RG, Thank you very much!
sal157011
Thank you for the indicator but could you better explain how the pivots are calculated with the standard deviation? On the chart above and last pivot could you explain what it is and how is calculated (0.65 EUR) and (4.93 %) and (23.743 M)? I've read the tooltips but still don't understand. In Dark Mode the ◯ alert point it is not visible, can you make possible to change its color?
brettkind
@sal157011, if high or low (if the last ZigZag Pivot was a high, then the low source) crosses the deviation line (the dotted line) a new fixed ZigZag Pivot point (⦿) will emerge/draw in the past. "◯" emerges on the current bar if the condition is true.

(0.65 EUR) and (4.93 %) and (23.743 M) for example are the mean values of the sum values. If the ZigZag Line has a length of 10 Bars and this 10 Bars have a sum volume of 500 then the mean value is (50). Volumen and the absoulte price change use the arethmetic mean for calculation. For the percentage values you need to take the geometric mean or CAGR, because the "normal" arethmetic average wouldnt be correct.

The ZigZag-deviation is calculated using standard deviation, true range, average true range, and the parameter minimum ZigZag deviation on the parameter SOURCE. The default Source is close. You can also calculate the stdev by using the function ta.bb() "bollinger bands" if you take the value of the upper band minus the moving average/mid band. Its the same value.

Sometimes the "◯" are drawn on the same bar as the "⦿"-points. I also use the darkmode and i can see them. The points are intentionally colored inconspicuously so that they do not obscure the actual information. In the statistical table, there is a value that describes the average deviation between the two points styles.

The purpose of these points is simply to provide a basic visualization that shows that this indicator cannot predict the future, and that the points (⦿) are added retroactively.
sal157011
@brettkind, Understood almost everything. Maybe plotting the alert point like a trailing stop line it would be nice, just saying.
brettkind
@sal157011, "◯" has no Y-Coordinates or Price. So you can not really plot it useful. It appears on the current bar if the condition is true.
(alertcondition(new_zigzag, title='New Fixed ZigZag Pivot ⦿', message='New ZigZag ⦿')
The Condition is when the Source crosses the dotted (deviation-)line.
brettkind
@sal157011, In the example on Mo 13 Nov' 23 there is a "◯"- Point on top of the Bar. So the condition was true on this day, so a new "⦿" emerged on Bar Mo 23 Oct' 23.
sam_m400
it is not showing the last candle zig zag data.. all data before the last zig zag is being shown ..Can you make it to show last zig zag data ?
brettkind
@sam_m400, Unfortunately, this is not possible in the current version of the indicator. But I will try to include this option in the next version.
Ariga
Hello. I cannot use the program. I get the message as follows: "Pine cannot determine the referencing length of a series. Try using max_bars_back"
更多