I don't know what I'm doing wrong here. It's just a simple MA of another indicator, but all it returns is -0. Please Help!
Thanks for looking!
function preMain(){
setStudyTitle("MoVoMA");
setCursorLabelName("MoVoMA", 0);
setPlotType(PLOTTYPE_LINE);
}
var vSum = 0;
var vSum1 =0;
var vSum2 =0;
var vTrend = 0;
function main(nInputLength){
if(nInputLength == null)
nInputLength = 18;
var nLength = nInputLength;
var i,j;
var vClose;
var vOpen;
var vVol;
var SumTrend ;
vClose = getValue("Close", 0, -3);
vOpen = getValue("Open", 0, -3);
vVol= getValue("Volume",0, -3);
vSum = (vClose[0]-vOpen[0])*vVol[0];
vSum1 = (vClose[1]-vOpen[1])*vVol[1];
vSum2 =(vClose[2]-vOpen[2])*vVol[2];
vTrend = (vSum+vSum1+vSum2)/30;
if(vTrend == null) {
return;
}
for(j = 0; j< nLength; j++) {
SumTrend += vTrend[j];
}
return SumTrend/nLength;
}
Thanks for looking!
function preMain(){
setStudyTitle("MoVoMA");
setCursorLabelName("MoVoMA", 0);
setPlotType(PLOTTYPE_LINE);
}
var vSum = 0;
var vSum1 =0;
var vSum2 =0;
var vTrend = 0;
function main(nInputLength){
if(nInputLength == null)
nInputLength = 18;
var nLength = nInputLength;
var i,j;
var vClose;
var vOpen;
var vVol;
var SumTrend ;
vClose = getValue("Close", 0, -3);
vOpen = getValue("Open", 0, -3);
vVol= getValue("Volume",0, -3);
vSum = (vClose[0]-vOpen[0])*vVol[0];
vSum1 = (vClose[1]-vOpen[1])*vVol[1];
vSum2 =(vClose[2]-vOpen[2])*vVol[2];
vTrend = (vSum+vSum1+vSum2)/30;
if(vTrend == null) {
return;
}
for(j = 0; j< nLength; j++) {
SumTrend += vTrend[j];
}
return SumTrend/nLength;
}
Comment