Cumulative volumes zigzag divergences

Category: Indicators By: Nicolas Created: February 19, 2018, 9:44 AM
February 19, 2018, 9:44 AM
Indicators
50 Comments

This indicator is based on volume analysis such as the one already posted here: ZigZag Cumulative Volume
In this version, bullish and bearish divergences are identified according to the volume accumulation and distribution waves in relation to the price.
The waves are calculated using the ZigZag indicator included in the platform.

  • Bearish divergence: if the volumes decline between 2 successive waves and the price increases (makes a new high), then a divergence would announce a possible lowering of the price.
  • Bullish divergence: if the volumes decline between two successive waves and the price decreases (makes a new low), then a divergence would announce a possible price increase.

The ZigZag waves are adaptable with their validation percentage in the indicator settings or in the code (default is 3%). It will of course be necessary to modify this value according to the instrument and the timeframe used.

Divergences are plotted on the indicator using segments between successive waves and red and green arrows.

Due to its natural behavior, the ZigZag indicator will retrace itself if a new higher or lower is found. As a result, the latest information in the chart may not be completely frozen in real time. On the other hand, in the case of the history of the price graph, the discrepancy information will always be indicated with the last known information which does not necessarily appear on the current bar, but afterwards when the highest or the lowest has has been validated.

Original idea of this indicator came from this French topic: Cumulative Volume Zig Zag – Divergences

//PRC_CumVol ZigZag Divergences | indicator
//14.02.2018
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge

// --- parameters
percentVariation = 3

zz = ZigZag[percentVariation](close)

peak = zz<zz[1] and zz[1]>zz[2]
tough = zz>zz[1] and zz[1]<zz[2]

if color=1 then
 cumV = cumV+volume
else
 cumV = cumV-volume
endif

if peak then

 lastpeakvol = peakvol
 lastpeakhigh = peakhigh
 lastpeakbar = peakbar
 peakvol = cumV[1]
 peakhigh = high[1]
 peakbar = barindex[1]

 cumV = -Volume

 color = -1
 r=255
 g=0

elsif tough then

 lasttoughvol = toughvol
 lasttoughlow = toughlow
 lasttoughbar = toughbar
 toughvol = cumV[1]
 toughlow = low[1]
 toughbar = barindex[1]

 cumV = Volume

 color = 1
 r=0
 g=255

endif

//divergences finder
divbear=0
divbull=0
//bearish divergence
if(peak) then
 if peakhigh>lastpeakhigh and peakvol<lastpeakvol then
  divbear = peakvol
  drawsegment(lastpeakbar,lastpeakvol,peakbar,peakvol) coloured(r,g,0)
  drawarrowdown(peakbar,peakvol) coloured(r,g,0)
 endif
endif
//bullish divergence
if(tough) then
 if toughlow<lasttoughlow and toughvol<lasttoughvol then
  divbull = toughvol
  drawsegment(lasttoughbar,lasttoughvol,toughbar,toughvol) coloured(r,g,0)
  drawarrowup(toughbar,toughvol) coloured(r,g,0)
 endif
endif

return cumV coloured(r,g,0) style(histogram), divbear coloured(255,100,0) style(histogram), divbull coloured(100,255,0) style(histogram)

 

Download
Filename: volumes-divergences.png
Downloads: 274
Download
Filename: PRC_CumVol-ZigZag-Divergences.itf
Downloads: 882
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Logo Logo
Loading...