Gentlemen,
Would you kindly take a look at the following code and see what is wrong with it? It gives nothing ... actually the debugprintlns don't even print...confused ....
var MAVt = new Array();
var MAVt1 =new Array();
var MAVt_1 = 0;
var MAVt1_1 = 0;
var nLength=7;var nSmoothing=4;var nSmoothings=10;var aCntr=3;
//
function preMain() {
setStudyTitle("zTest");
setCursorLabelName("zTest");
setPriceStudy(false);
}
function main() {
var percentK; var Mt1=0;var Mt2=0;
var ll = 0, hh = 0;
var sum = 0;
var vHigh = getValue("High", 0, -nLength);
var vLow = getValue("Low", 0, -nLength);
var temp = 0; tmp1=0;
if(vHigh == null || vLow == null)
return;
for(j = 0; j < nLength; j++) {
if(j == 0) {
ll = vLow[j];
hh = vHigh[j];
} else {
hh = Math.max(hh, vHigh[j]);
ll = Math.min(ll, vLow[j]);
}
}
percentK = ((close() - ll) / (hh - ll)) * 100;
if (isNaN(percentK) == false) Mt1 = MAVt_1 + (percentK - MAVt_1) / nSmoothing;
if (MAVt.length<aCntr) tmp1=MAVt.unshift(Mt1);
else {tmp1=MAVt.pop(); tmp1=MAVt.unshift(Mt1);}
if (getBarState() == BARSTATE_NEWBAR) MAVt_1 = MAVt(0);
if (isNaN(percentK) == false) Mt2 = MAVt1_1 + (MAVt(0) - MAVt1_1) / nSmoothings;
if (MAVt1.length<aCntr) tmp1=MAVt1.unshift(Mt2);
else {tmp1=MAVt1.pop(); tmp1=MAVt1.unshift(Mt2);}
if (getBarState() == BARSTATE_NEWBAR) MAVt1_1 = MAVt1(0);
var pK0=MAVt(0);
var pK1=MAVt(1);
var pK2=MAVt(2);
var pD0=MAVt1(0);
var pD1=MAVt1(1);
var pD2=MAVt1(2);
debugPrintln("in Main zTest");
debugPrintln("pk1 pd1: "+pK1+" "+pD1);
if (pK0>pD0){
setBarFgColor(Color.black);
setBarBgColor(Color.blue);
}else if (pK0>pD0) {
setBarFgColor(Color.black);
setBarBgColor(Color.red);
}else {
setBarFgColor(Color.black);
setBarBgColor(Color.yellow);
}
}
...the feeble mind
Would you kindly take a look at the following code and see what is wrong with it? It gives nothing ... actually the debugprintlns don't even print...confused ....
var MAVt = new Array();
var MAVt1 =new Array();
var MAVt_1 = 0;
var MAVt1_1 = 0;
var nLength=7;var nSmoothing=4;var nSmoothings=10;var aCntr=3;
//
function preMain() {
setStudyTitle("zTest");
setCursorLabelName("zTest");
setPriceStudy(false);
}
function main() {
var percentK; var Mt1=0;var Mt2=0;
var ll = 0, hh = 0;
var sum = 0;
var vHigh = getValue("High", 0, -nLength);
var vLow = getValue("Low", 0, -nLength);
var temp = 0; tmp1=0;
if(vHigh == null || vLow == null)
return;
for(j = 0; j < nLength; j++) {
if(j == 0) {
ll = vLow[j];
hh = vHigh[j];
} else {
hh = Math.max(hh, vHigh[j]);
ll = Math.min(ll, vLow[j]);
}
}
percentK = ((close() - ll) / (hh - ll)) * 100;
if (isNaN(percentK) == false) Mt1 = MAVt_1 + (percentK - MAVt_1) / nSmoothing;
if (MAVt.length<aCntr) tmp1=MAVt.unshift(Mt1);
else {tmp1=MAVt.pop(); tmp1=MAVt.unshift(Mt1);}
if (getBarState() == BARSTATE_NEWBAR) MAVt_1 = MAVt(0);
if (isNaN(percentK) == false) Mt2 = MAVt1_1 + (MAVt(0) - MAVt1_1) / nSmoothings;
if (MAVt1.length<aCntr) tmp1=MAVt1.unshift(Mt2);
else {tmp1=MAVt1.pop(); tmp1=MAVt1.unshift(Mt2);}
if (getBarState() == BARSTATE_NEWBAR) MAVt1_1 = MAVt1(0);
var pK0=MAVt(0);
var pK1=MAVt(1);
var pK2=MAVt(2);
var pD0=MAVt1(0);
var pD1=MAVt1(1);
var pD2=MAVt1(2);
debugPrintln("in Main zTest");
debugPrintln("pk1 pd1: "+pK1+" "+pD1);
if (pK0>pD0){
setBarFgColor(Color.black);
setBarBgColor(Color.blue);
}else if (pK0>pD0) {
setBarFgColor(Color.black);
setBarBgColor(Color.red);
}else {
setBarFgColor(Color.black);
setBarBgColor(Color.yellow);
}
}
...the feeble mind
Comment