## Dual Volume Divergence Index

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

### Dual Volume Divergence Index

Code:

//@version=2
study(title="Dual Volume Divergence Index [DW]", shorttitle="DVDI [DW]")
//by Donovan Wall

//This is an experimental variation of Paul L. Dysart's Positive Volume Index and Negative Volume Index that tracks the divergences between the PVI and its EMA, and the NVI and its EMA, then plots both together for comparison.
//This tool can be used to identify trending price activity.

//----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Inputs
//----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Period
per = input(255, minval=1, title="EMA Period")

//----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Definitions
//----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Rate of Change
roc = roc(close, 1)

//Positive Volume Divergence Index
pvi = volume > volume[1] ? nz(pvi[1]) + roc : nz(pvi[1])
psig = ema(pvi, per)
pdiv = pvi - psig
pcolor = pvi > psig ? lime : pvi < psig ? red : na

//Negative Volume Divergence Index
nvi = volume < volume[1] ? nz(nvi[1]) - roc : nz(nvi[1])
nsig = ema(nvi, per)
ndiv = nvi - nsig
ncolor = nvi < nsig ? lime : nvi > nsig ? red : na

//Divergence Color
dcolor = (pdiv > ndiv) and (pdiv < 0) ? green : (pdiv > ndiv) and (pdiv > 0) ? lime : (ndiv > pdiv) and (ndiv < 0) ? maroon : (ndiv > pdiv) and (ndiv > 0) ? red : na

//Center
cent = 0

//----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Plots
//----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Index Center
centplot = plot(cent, color=orange, title="Center Line")

//Index Plots
pplot = plot(pdiv, color=lime, title="PVI Divergence")
nplot = plot(ndiv, color=red, title="NVI Divergence")

//Fills
fill(pplot, nplot, color=dcolor, transp=60)

//Bar Colorization
barcolor(dcolor)
isamegrelo

Posts: 95
Joined: Mon May 29, 2017 3:36 pm

### Re: Dual Volume Divergence Index

Apprentice
FXCodeBase: Confirmed User

Posts: 19568
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia