@hariprasathgopal, please re-examine the sample code for this function to understand better how it works.
Anyway, here is a short example, derived from that example, that shows you how to plot something (distribution will be built "every" x bars):
GfxSetZOrder( -1 );
GfxSetCoordsMode( 1 );
GfxSelectPen( colorGrey50 );
// limit the VAPs to the visible bars
every = 5;
bi = BarIndex();
fvb = Max(0, FirstVisibleValue( bi ) - every);
lvb = LastVisibleValue( bi );
bins = 100;
for( j = fvb; j <= lvb; j += every )
{
startbar = j;
endbar = Min( ( j + every ), lvb );
if( startbar != endbar )
{
mx = PriceVolDistribution( H, L, V, bins, False, startbar, endbar );
bins = MxGetSize( mx, 0 );
for( i = 0; i < bins; i++ )
{
price = mx[ i ][ 0 ]; // price level
relvolume = mx[ i ][ 1 ]; // relative volume 0..1
reendbarar = relvolume * ( endbar - startbar + 1 );
GfxMoveTo( startbar, price );
GfxLineTo( startbar + reendbarar, price );
}
}
}
Plot( C, "Price", colorDefault, styleBar );
Keep in mind that this function may fail anyway if the supplied data ( H, L, V) for the indicated range between the startbar and the endbar is invalid/null.
So, for now, please, apply the above snippet to a ticker with consistent data (no holes).
In your full-fledged formula you may address this issue validating the data in advance and skipping the function calls and its associated plots when data is irregular.
When you got the basics, you have to figure out how to build your chart in a more meaningful way, like display a reimplemented VAP for every day when using intraday data, every week for daily bars, overlapping multiple VAPs, etc.