Since there is no volume associated with $COMPQ I made one.
It derives a bar by bar indicator by subtracting the open from the close on $TVOLQ and plots as histogram. Seems to work well. I'm trying to add a moving average of this volume to plot on top of the volume histogram but can not get it to plot the MA. Could someone taek a look at this and tell me how to get the MA of volume to Plot? Right now all I get is a straight line for the Ma of the volume. Would be most appreciated.
Here is the efs.
function preMain() {
setStudyTitle("Naz Vol");
setCursorLabelName("Naz Vol", 0);
setCursorLabelName("Ave Vol", 1);
setPlotType(PLOTTYPE_HISTOGRAM,0);
setDefaultBarThickness(3);
setDefaultBarFgColor(Color.blue, 0);
setPlotType(PLOTTYPE_LINE, 1);
setDefaultBarFgColor(Color.purple, 1);
addBand(0, PS_SOLID, 1, Color.black,2);
}
function main(nInputLength) {
if (nInputLength == null)
nLength = 50;
var nLength = nInputLength;
var i;
var vSum;
var vValue = close(0,1,"$TVOLQ")-open(0,1,"$TVOLQ");
if(vValue == null) {
return;
}
for(i = 0; i < nLength; i++) {
vSum += vValue[i];
}
return new Array(vValue, vSum/nLength);
}
It derives a bar by bar indicator by subtracting the open from the close on $TVOLQ and plots as histogram. Seems to work well. I'm trying to add a moving average of this volume to plot on top of the volume histogram but can not get it to plot the MA. Could someone taek a look at this and tell me how to get the MA of volume to Plot? Right now all I get is a straight line for the Ma of the volume. Would be most appreciated.
Here is the efs.
function preMain() {
setStudyTitle("Naz Vol");
setCursorLabelName("Naz Vol", 0);
setCursorLabelName("Ave Vol", 1);
setPlotType(PLOTTYPE_HISTOGRAM,0);
setDefaultBarThickness(3);
setDefaultBarFgColor(Color.blue, 0);
setPlotType(PLOTTYPE_LINE, 1);
setDefaultBarFgColor(Color.purple, 1);
addBand(0, PS_SOLID, 1, Color.black,2);
}
function main(nInputLength) {
if (nInputLength == null)
nLength = 50;
var nLength = nInputLength;
var i;
var vSum;
var vValue = close(0,1,"$TVOLQ")-open(0,1,"$TVOLQ");
if(vValue == null) {
return;
}
for(i = 0; i < nLength; i++) {
vSum += vValue[i];
}
return new Array(vValue, vSum/nLength);
}
Comment