Zig-Zag Donchian indicator

Zig-Zag Donchian indicator

1. Introduction

The Zig-Zag Donchian indicator is a technical analysis tool that combines the logic of the Zig-Zag with Donchian channels to identify turning points in the price direction of an asset. This indicator is especially useful for traders looking to detect emerging trends, local highs and lows, as well as potential buy and sell signals.

The Zig-Zag Donchian is based on the concept of identifying the most significant price movements, filtering out market noise, and highlighting meaningful changes. Unlike the traditional Zig-Zag indicator, which focuses solely on price pivots, the Zig-Zag Donchian uses Donchian channels to establish upper and lower boundaries that help validate trend changes. This allows traders to gain a clearer view of market dynamics and make informed decisions based on the interaction of price with these bands.

This indicator adapts well to different financial assets, and its customization options allow it to be adjusted to the specific characteristics of the market in which it is being used, whether it’s a stock market, forex, commodities, or cryptocurrencies.

2. How the Zig-Zag Donchian Works

The Zig-Zag Donchian works by combining the calculation of Zig-Zag pivots with Donchian channels, which are constructed using the highest and lowest price values over a specified period. This combination allows the indicator to identify turning points in the price direction, providing a clearer view of the current trend and potential reversal points.

The indicator uses a set of customizable parameters that allow it to be tailored to different assets and market conditions:

  • Length: This parameter determines the number of bars used to calculate the upper and lower levels of the Donchian channels. A higher value will smooth the bands and generate fewer signals, while a lower value will make the indicator more sensitive to price changes.
  • Bounce Speed (bsp): The bounce speed is a factor that affects how quickly the Zig-Zag adjusts to changes in price. A higher value makes the Zig-Zag more responsive to directional changes in price.
  • Transparency (transp): This parameter allows you to adjust the transparency of the Donchian channel fill on the chart, improving the visualization of the channel in combination with other chart elements.
  • Gradient (gradient): This parameter activates the gradient color function for the Donchian channel, providing a visual representation that shows the position of the price within the range.
  • Show Signals (showsignals): This parameter enables or disables the visualization of buy and sell signals based on the Zig-Zag pivots.

In its functionality, the indicator identifies price crossings with the Donchian channels and, based on these crossings, generates signals indicating potential trend changes. The Zig-Zag pivots adjust according to changes in price direction, allowing the trader to observe how the price interacts with the upper and lower levels of the Donchian channel.

This process provides an effective visual tool for identifying dynamic support and resistance zones, as well as anticipating potential reversals in market trends.

3. Calculation of Donchian Channels

The Zig-Zag Donchian uses Donchian channels to identify the highest and lowest price levels within a defined period. These channels are constructed by taking the highest and lowest values of the price (by default, the closing price) over a specified number of bars. This helps establish the upper and lower boundaries within which the price will move.

In the code, the Donchian channels are calculated using the following commands:

  • upper: Defines the upper limit of the Donchian channel and is calculated by identifying the highest price reached during the period specified by the length parameter.
  • lower: Defines the lower limit of the Donchian channel and is obtained by finding the lowest price during the same period.

The length parameter determines the number of bars that will be used for this calculation. By default, a value of 20 is used, meaning that the indicator will consider the most recent 20 periods to determine the upper and lower levels.

These bands serve as dynamic references to identify the price range’s amplitude over a specific period. Using Donchian channels in combination with the Zig-Zag provides traders with information about zones where the price might find resistance (upper level) or support (lower level), helping to anticipate potential trend reversal points.

4. Calculation of the Zig-Zag

The Zig-Zag component of the indicator is responsible for identifying turning points in the price direction within the Donchian channels. The goal is to eliminate market noise and highlight only the most relevant movements, facilitating the identification of local highs and lows.

The calculation of the Zig-Zag is based on the following steps:

  1. Detection of crossings with Donchian channels: The Zig-Zag checks whether the price has crossed the upper or lower Donchian channels. The conditions are:

    Here, zz represents the current value of the Zig-Zag, and zz[1] is its value in the previous bar. If a crossing with the upper or lower band is detected, a signal indicating a change in direction is generated.

  2. Determination of the oscillator (osc): The osc oscillator indicates the direction of the price movement and is defined as:

    • When a crossing with the upper band (crossupper) occurs, the oscillator takes a value of -1, indicating a potential shift to a bearish trend.
    • When a crossing with the lower band (crosslower) occurs, the oscillator is set to 1, signaling a possible shift to a bullish trend.
  3. Zig-Zag update: If a change in the oscillator direction is detected, the difference between the upper and lower bands (val) is calculated to adjust the Zig-Zag value:

    Finally, the Zig-Zag value is updated using the formula:


    The final result is a Zig-Zag indicator that follows price movements within the limits set by the Donchian channels, providing a clear visual approach to identifying directional changes and market trends.

5. Visualization of the Donchian Channel

The Zig-Zag Donchian indicator not only uses Donchian channels to detect price reversal points but also displays them visually on the chart, providing a clear representation of the price range. To enhance the interpretation of price movements, the Donchian channel is filled with a color gradient indicating the price’s position within the range.

Gradient Color Calculation

The indicator calculates the current position of the price within the Donchian channels using the following formula:

  • source: Represents the normalization of the price position (src) within the channels. It takes a value between 0 and 1, where 0 indicates the price is at the lower band and 1 indicates it’s at the upper band.
  • norm: Calculates an average of source over the length period to smooth variations.

This normalized value is used to determine the color of the Donchian channel, applying different shades based on the price’s position within the range.

When norm is low, the channel is shown in red tones, indicating that the price is close to the lower level. As norm increases, the color gradually changes from orange to yellow, green, and finally to bright green when the price nears the upper level.

This gradient helps visualize price movement within the channel, providing additional information about the current trend’s strength.

Filling the Donchian Channel

The indicator uses the colorbetween() function to fill the channel between the upper and lower levels with the calculated colors, applying the transparency defined by the transp parameter:

6. Buy and Sell Signals

The Zig-Zag Donchian generates buy and sell signals based on the pivots detected by the Zig-Zag component. These signals help traders identify entry and exit points in the market, making it a comprehensive tool for technical analysis.

  • Sell Signal (Red Arrow): Generated when a local high is detected, i.e., when the current value (zz) is lower than the previous value (zz[1]) and the value two periods ago (zz[2]). This indicates a possible downward reversal, and a red arrow is drawn on the chart.
  • Buy Signal (Green Arrow): Produced when a local low is detected, meaning the current value (zz) is higher than the previous (zz[1]) and the one two periods ago (zz[2]). This indicates a potential upward reversal, and a green arrow is displayed on the chart.

7. Customizable Parameters

The Zig-Zag Donchian is a flexible indicator that allows you to adjust several parameters to adapt it to different financial assets and market conditions.

  • length: The number of bars used to calculate the Donchian channels.
  • bsp: Bounce speed multiplier affecting how quickly the Zig-Zag responds.
  • transp: Transparency level for the Donchian channel fill.
  • gradient: Controls the gradient colors for the channel.
  • showsignals: Enables or disables buy and sell signals.

8. Zig-Zag Donchian Indicator Code

9. Conclusion

The Zig-Zag Donchian is a versatile and powerful tool that combines Zig-Zag pivots with Donchian channels to offer a clear visual representation of trends and turning points. With its customizable parameters, this indicator can be tailored to suit various trading strategies, making it an invaluable resource for traders aiming to enhance their accuracy in identifying trading opportunities.

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

  1. roccafragius • 54 days ago #

    Hello Ivan, another great Indicator, very useful to trace the trend ( blue line) and the possible Breakout ( price over/under the blue line)!! Thank you!

avatar
Register or

Likes

avatar avatar avatar avatar
Related users ' posts
Fgats Ivan can you please explain a line of code that is puzzling me. This is line 37 . As I unde...
teshmi9z Hola, ¿es posible detectar cuándo el precio regresa a la zona del 61 al 88 % de Fibonacci y,...
kats Bonjour, J'ai une question etes vous trader? Je m'explique , j'ai téléchargé tous les indi...
philippe59139 Bravo super travail
gidien
10 months ago
gidien Thanks for the hint. I think i know now, why this happen. The "settings" block was added by ...
LucasBest Thank you for sharing your work, both original and very disconcerting. When I went through t...
gidien Hello LucasBest, thanks for your comment. Point 1: Yes your are right. The Zigzag ve...
luxrun A question: what are the initial (or default) values ​​of maximum and minimum in the executi...
NEOMKEY Excelente trabajo. Lo uso también en scalping de 1 minuto.
philippe59139 bonjour zeiiermantrading , merci pour ton excellent travail, je me suis permis de rajouter ...
Bodaris Bonjour, je tenais à vous remercier pour votre travail et votre partage. J'utilise beaucoup ...
Nicolas
1 year ago
Florian Hello Nicolas, This indicator repainting ?
Nicolas It's impossible for it to repaint the values of the past.
steffen_burat Hello Nicolas, I have a cumulative histogram update problem, the indicator often updates ...
taklause Hello Nicolas, if I try to use your indicator in a trading system, the error on prc pops up ...
Gio56 Bonjour Nicolas J'ai le meme souci que steffen , l'indicateur ne cumule qu'après avoir redé...
jonpt88 hI . THIS LOOKS GOOD. Thanks. Just one doubt: is this kind of impulse indicator - does it sh...
effegi
2 years ago
effegi A good alternative solution, even I had thought of the variant that uses high and low (proba...
Seb did you automate that 1-2-3 strategy? how is that working for you?
effegi Not yet, I'm busy developing other strategies/indicators at the moment, but it's on my to-do...
DELBERT Bonjour , Nicolas , je voudrais installer cet indicateur sur ma PRT , version 10.3 , mais je...
Nicolas En effet, il faut à minima une version 11. La 10.3 est tellement ancienne maintenant.. Je pe...
DELBERT Bonjour , Nicolas , merci pour ta réponse , je fais un essai et je verrais . Salutations .
StephFor //ind1 = ZigZagPoint[2*averagetruerange[200]](close) avr = 3 //3% ind1 = ZigZag[avr](close...
Manu L. @Steph un grand merci pour ton aide mais :-( J'ai copier le code tel quel mais cependant j...
AlphaMauss Je n'ai pas réussi à faire fonctionner l'indicateur avec le code fourni en commentaire sur P...
ribes65 Bonjour Nicolas, Merci pour votre travail. Est-il envisageable de créer un screener pour ...
Nicolas Bien sûr, merci de formuler une demande dans le forum des screeners pour prorealtime. En res...
ipbvba Est il possible de le transformer en indicateur (pour ne plus avoir les lignes mais uniqueme...
Meta Signals Pro Pleasure ! Please let us know if you make good trades with it and if you see improvements we...
francis59 Bonjour, Bonjour, comment puis-je créer un screener basé sur cet indicateur, qui affiche le...
Trader Sab I am curious to try it how, however I get an error message for line 47 and 48 - drawsegment,...
Byggtrader Hi Nicolas! How do I get the indicator in the price chart? It only stays under i new chart.
Nicolas Just add it on the price chart by using the wrench on the left upper side of the chart (pric...
datageek How do I change the thickness of the line or change it too dashed lines? Kind regards
lkiklkik NE fonctionne pas ( ou plus ... )
Nicolas il faut modifier toutes les références à top par itop et bottom par ibottom. Ces mots étant ...
teddy58 Ich habe es mit N= 1,5 und N=2,5 getestet mit 200000 Einheiten. Es funktioniert leider erst ...
Matriciel I use this indicator to help me make a decision when there is a divergence. The divergences ...
Jan Wind Hi, I personnaly am not a big fan of ZIGZAG indicator, as it repaints itself during time. ...
Nicolas Sure, I suggest you open a new topic in the forum to discuss about your ideas.
hdgm Bonjour Nicolas, est ce que l'on peut en faire une stratégie de trading automatisée ?
Nicolas Non, pas en utilisant l'indicateur zigzag traditionnel de la plateforme.
TACBOLSA
6 years ago
Tradingrob Hi Tac Bolsa, thanks for the information. But after carefully ready all the material i still...
TAC Bolsa Hello, the indicator creates the support depending on the volume and is dynamic.
carlvan Not working on PRT 11.1. And the site https://www.tiburonesdealetacorta.com does not exist....

Top