Really there is zero code in your post so no one knows what you are actually doing.
Also no one knows whether it is AFL or C code. It might be latter one since it is plugins section but no one knows for certain.
Actually it does not matter. All that matter is: PriceVolDistribution is type matrix and it always has n-rows for all of its two columns. And there is always even number of elements.
Cells do not contain nothing. You simply misinterpret your output.
Your output is rather like this
i0=2.8026e-44,
i1=2.8026e-45,
Now two columns with twenty rows follow (since you have set 20 bins).
First column is price and second column is volume (relative or absolute depending on setting).
i2=10705, i3=0.191417,
i4=10741.8, i5=0.432163,
i6=10778.7, i7=0.111025,
i8=10815.5, i9=0.155798,
i10=10852.4, i11=0.151392,
i12=10889.2, i13=0.326764,
i14=10926.1, i15=0.278761,
i16=10962.9, i17=0.451915,
i18=10999.7, i19=0.310034,
i20=11036.6, i21=0.137222,
i22=11073.4, i23=0.486567,
i24=11110.3, i25=0.146257,
i26=11147.1, i27=0.304363,
i28=11183.9, i29=0.444949,
i30=11220.8, i31=0.70814,
i32=11257.6, i33=0.881979,
i34=11294.5, i35=1,
i36=11331.3, i37=0.486313,
i38=11368.2, i39=0.256732,
i40=11405, i41=0.0895762
i0
and i1
are some garbage output not related to distribution matrix (or result of incorrect code).
You need to check your code. It is your code. No one knows your code.
Since you have not posted code here is AB user guide code just adding print output.
/// a demo showing
/// re-implementation of VAP overlay using
/// PriceVolDistribution and low-level graphics
/// @link https://www.amibroker.com/guide/afl/pricevoldistribution.html
bi = BarIndex();
fvb = FirstVisibleValue( bi );
lvb = LastVisibleValue( bi );
param_bins = Param( "Bins", 20, 10, 100, 1 );
mx = PriceVolDistribution( H, L, V, param_bins, False, fvb, lvb );
printf( "%s\n\n", MxToString(mx));
GfxSetCoordsMode( 1 );
GfxSelectPen( colorRed );
bins = MxGetSize( mx, 0 );
printf( "ALWAYS even number of matrix elements: %g\n\n",
MxGetSize(mx,0)*MxGetSize(mx,1));
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 );
printf( "row idx: %g, %g, %g\n", i, price, relvolume);
GfxMoveTo( fvb, price );
GfxLineTo( fvb + relbar, price );
}
Plot( C, "Price", colorDefault, styleBar );
Setting n-bins results in n-rows for all columns.
Bottom line PriceVolDistribution function works fine and correctly.
