# Cumulative Volume ZigZag (live version)

This Cumulative Volume indicator helps in understanding the change in volume related to peaks and troughs (referred to as ‘tough’ in the code) of price movement based on the ZigZag indicator.

Here is a detailed explanation of the code:

1. `defparam drawonlastbaronly=true`: This line sets the parameter to draw the indicator only on the last bar of the chart to save computation resources.
2. The parameters are set: `percentVariation` is set to 0.04, which defines the minimum price change necessary for the ZigZag indicator to alter its direction. `BarsLimit` is set to 200, which is the maximum number of bars for which the histogram is drawn.
3. `zz = ZigZag[percentVariation](close)`: This line calculates the ZigZag indicator based on the closing prices and the percent variation defined.
4. `peak = zz<zz[1] and zz[1]>zz[2]` and `tough = zz>zz[1] and zz[1]<zz[2]` are lines that define conditions for identifying peaks and troughs. A peak is identified when the current ZigZag value is less than the previous value and the previous value was greater than the one before it. Similarly, a trough is identified when the current ZigZag value is greater than the previous one and the previous value was less than the one before it.
5. `cumV = cumV+volume`: This line is used to calculate the cumulative volume up to the current bar.
6. The array `\$barvol` is used to store the cumulative volume for each bar. The `\$barcolor` array is used to store the color for the current trend.
7. If a peak or trough is identified, the cumulative volume (`cumV`) is reset to the current bar’s volume, and the trend color (`color`) is set accordingly. If a peak is identified, `color` is set to -1, indicating a downward trend. If a trough is identified, `color` is set to 1, indicating an upward trend.
8. The `if islastbarupdate then` block is executed on every last bar update. It draws rectangles on the last `BarsLimit` number of bars based on the stored volumes and colors.
9. `return cumV coloured(0,0,0,0)` : This line is to return the current cumulative volume as the value of the indicator. The color of this line is set to transparent (all zeros), meaning that the line won’t be visible on the chart. The visual representation of this indicator is done by the rectangles drawn in the previous step.

This code will effectively create a volume histogram where the color of each bar represents the direction of the trend, and the height of the bar represents the cumulative volume of the trend. Peaks and troughs will reset the cumulative volume, starting a new bar in the histogram.

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. • 354 days ago #

Il y a une erreur dans le code après installation. “Un caractère de type entier est attendu avec barcolor”

• • 354 days ago #

Il doit y avoir impérativement plus d’unités affichées que le paramètre “BarsLimit”. Ceci étant j’ai contasté une erreur dans cette version sur la mise à jour de la dernière jambe du zigzag, je corrigerai bientôt.

2. • 306 days ago #

Hello Nicolas,

I have a cumulative histogram update problem, the indicator often updates or cumulate only after restarting the indicator, what should I try to do?

3. • 176 days ago #

Hello Nicolas, if I try to use your indicator in a trading system, the error on prc pops up that that the indicator (ZigZag) contains code that the current “backtest monitor” does not support. Is there a way to fix this? Thanks for replying.

Register or

#### Likes

Related users ' posts
Iván
1 month ago
4
Indicators
;)
Magnífico !!!. Al menos para mí. Gran trabajo con tus aportes Iván. Mira a ver si le incluye...
jajaja gracias :)
Iván
3 months ago
4
Indicators
I personally like it in daily timeframe
Many thanks Ivan, I copy/paste your code to try it but could only get a constant stable unif...
Hi, I've copied the code above and it works... what asset are you trying? \$indices array ...
philippe59139
4 months ago
7
Indicators
Bonjour Je pense que votre indicateur est très bon. Serait-il possible d'afficher la heatma...
if marketEtHeamap=1 then drawtext("#touch#",barindex+10,checkprice,SansSerif,Standard,10) c...
voici pour toi RAZZ il te faut simplement ajouter les drawtext https://www.prorealcode.com...
gidien
5 months ago
1
Indicators
Bravo super travail
gidien
5 months ago
5
Indicators
Thanks for the hint. I think i know now, why this happen. The "settings" block was added by ...
Thank you for sharing your work, both original and very disconcerting. When I went through t...
Hello LucasBest, thanks for your comment. Point 1: Yes your are right. The Zigzag ve...
JS
11 months ago
0
Indicators
luxrun
11 months ago
0
Indicators
effegi
1 year ago
1
Indicators
hI . THIS LOOKS GOOD. Thanks. Just one doubt: is this kind of impulse indicator - does it sh...
effegi
1 year ago
6
Indicators
A good alternative solution, even I had thought of the variant that uses high and low (proba...
did you automate that 1-2-3 strategy? how is that working for you?
Not yet, I'm busy developing other strategies/indicators at the moment, but it's on my to-do...
Nicolas
2 years ago
3
Indicators
Hi Nicolas! I can´t install this indicator. it installs in a separate window not as an av...
No consigo instalarlo en el precio en PRL-version 10
Khaled
2 years ago
4
Indicators
As this section of the forum is in English, I'll reply in English. I'm using PRT v11, so I d...
Don't understand where it says: "Volume Pressure Histogram: Columns plotted in positive are ...
Not sure to understand the question. However, the columns (Histogram) represent the variable...
Nicolas
2 years ago
6
Indicators
Cela fonctionne très bien !!! Super Merci
Ciao Nicolas, molto bello questo indicatore, l'ho apprezzato molto. Lo sto testando insieme...
Je poste ici un lien afin de mieux appréhender le CVD-Cumulative Volume Delta : https://www....
Nicolas
2 years ago
4
Indicators
Bonsoir , Nicolas , j'ai transféré votre indicateur sur ma PRT 10,3 et j'ai un méssage d'ére...
Vous pouvez essayer en remplacant la ligne avec: vwapsd = sqrt(average[lengthz](square(clo...
Bonsoir , merci Nicolas , a bientôt .
teamone
2 years ago
0
Indicators
Jiankyr82
2 years ago
0
Screeners
Nicolas
3 years ago
v10.3
2
Indicators
Bonjour Nicolas, j'ai récemment découvert cet indicateur (Regularized Momentum 2017) et je l...
Bonjour, nouveau sur PRT (qq jours), j'essaie un peu de voir quel type d'indicateur me convi...
4 years ago
v10.3
6
Indicators
I don't know in this case, I just downloaded it again and no problem for me. Try to downloa...
What's the error that appears ?
Yes, it worked with 1Tick with 200 K . Thank you very much.
4 years ago
v10.3
4
Indicators
Hi Daniele Thank you for the indicator, it looks very good. However, I have a problem so...
Anonymous Thanks very much for sharing, look forward to testing this idea out.
Thank you Daniele for making this script, I know its been some time since the release but wo...
Seb
4 years ago
23
Screeners
//ind1 = ZigZagPoint[2*averagetruerange[200]](close) avr = 3 //3% ind1 = ZigZag[avr](close...
@Steph un grand merci pour ton aide mais :-( J'ai copier le code tel quel mais cependant j...
Je n'ai pas réussi à faire fonctionner l'indicateur avec le code fourni en commentaire sur P...
robertogozzi
4 years ago
3
Indicators
Apparently, according to the attached data, there is an error in the indicator code. Attach...
The files are at the end of the following link: https://www.prorealcode.com/topic/time-seg...
Thank you Barrabas15, the correct code is at https://www.prorealcode.com/topic/time-segmente...

Top