When I use this code on an index like $SPX, $NDX, etc. -- Volume(0) is returning a value other than 0 (zero). Historical bars are fine - only the current bar has a steadily increasing value. Works fine on stocks that have volume.
PHP Code:
debugClear;
bInit = false;
function main() {
if (!bInit) {
xVol = volume();
xMAV = sma(5, xVol );
bInit=true;
}
nVol = xVol.getValue(0);
nAvgVol = xMAV.getValue(0);
debugPrintln(volume(0) + " " + nVol + " " + nAvgVol);
return;
}