PriceVolDistribution
- general-purpose distribution function

Matrix functions
(AmiBroker 6.20)


SYNTAX PriceVolDistribution( priceH, priceL, vol, bins, absolute = False, startbar = 0, endbar = -1 )
RETURNS MATRIX
FUNCTION The function is general purpose frequency distribution function. It is typically used to create distribution of volume versus price but this is only one of many possible uses. The function takes priceH, priceL and vol arrays and outputs distribution MATRIX with price levels in first column and relative volume at that level in second column. The bins parameter decides how many price 'bins' the distribution will have. The absolute parameter decides whenever returned volumes are absolute sum or relative (0...1) values. The startbar and endbar decides which bars from input array should be used.
EXAMPLE // a demo showing
// re-implementation of VAP overlay using
// PriceVolDistribution and low-level graphics
bi = BarIndex();
fvb = FirstVisibleValue( bi );
lvb = LastVisibleValue( bi );

mx = PriceVolDistribution( H, L, V, 100, False, fvb, lvb );

GfxSetCoordsMode( 1 );

GfxSelectPen( colorRed );

bins = MxGetSize( mx, 0 );
for( i = 0; i < bins; i++ )
{
price = mx[ i ][ 0 ]; // price level
relvolume = mx[ i ][ 1 ]; // relative volume 0..1
relbar = relvolume * (lvb-fvb+1);
GfxMoveTo( fvb, price );
GfxLineTo( fvb + relbar, price );
}

Plot( C, "Price", colorDefault, styleBar );

if( ParamToggle("BuildinVAP", "No|Yes") ) PlotVAPOverlay( 100, 100, colorGreen, 2 );
SEE ALSO

References:

The PriceVolDistribution function is used in the following formulas in AFL on-line library:

More information:

See updated/extended version on-line.