Newbie having trouble coding the following:
new value = (previous value)*0.9 + current value of sym("$ADD")*0.1
What am I doing wrong?
new value = (previous value)*0.9 + current value of sym("$ADD")*0.1
What am I doing wrong?
PHP Code:
function main(nLength) {
if(nLength == null)
nLength = 30;
var nSum = new Array;
nSum = 0;
var vValue = getValue("Close", 0, -nLength, "$ADD");
if(vValue == null) {
return;
}
for(i = 0; i < nLength; i++) {
nSum[i] = 0.9*nSum[i-1] + 0.1*vValue[i];
}
return (nSum);
}
Comment