Cut and past the script then load it and you will get a reference error message; "myDCHstudy1 is not defined" .
I have written many script that are very similiar in form and I don't know why this error is occuring.
Next cut; vVClose = getValue("Close", 0, -Lgth);
//if (vVClose == null) return;
and paste it below; if (vValueH1 == null|| vValueL1 == null ) return;
Then load the script and you will get no error message but there will be no values for vVClose.
I am stumped. As I said I have written a varity of scriptd that follow the same form and have not had these problems.
Thanks for the help.
function preMain(){
setStudyTitle("DCH ROC");
setCursorLabelName("ROC",0);
setDefaultBarFgColor(Color.red,0);
setPriceStudy(false);
var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
fp1.setName("DCH Length");
fp1.setDefault(4);
fp1.setLowerLimit(1);
var fp2 = new FunctionParameter("Lgth", FunctionParameter.NUMBER);
fp2.setName("Close Length");
fp2.setDefault(8);
fp2.setLowerLimit(1);
}
var vVClose = null;//vValueH1 = null, vValueL1 = null,
function main(Length, Lgth){
var vSm, vValueH1, vValueL1;
vVClose = getValue("Close", 0, -Lgth);
//if (vVClose == null) return;
if (getBarState() == BARSTATE_ALLBARS) {
myDCHstudy1 = new DonchianStudy(Length, 0);
}
vValueH1 = myDCHstudy1.getValue(DonchianStudy.UPPER);
vValueL1 = myDCHstudy1.getValue(DonchianStudy.LOWER);
if (vValueH1 == null|| vValueL1 == null ) return;
// vSm = 0;
//for(i = 0; i < Lgth+1; i++) {
// vSm += vC[i] - vC[i + 1];
// }
//vSm = vSm/(vValueH1-vValueL1);
return new Array ( vVClose );
}
I have written many script that are very similiar in form and I don't know why this error is occuring.
Next cut; vVClose = getValue("Close", 0, -Lgth);
//if (vVClose == null) return;
and paste it below; if (vValueH1 == null|| vValueL1 == null ) return;
Then load the script and you will get no error message but there will be no values for vVClose.
I am stumped. As I said I have written a varity of scriptd that follow the same form and have not had these problems.
Thanks for the help.
function preMain(){
setStudyTitle("DCH ROC");
setCursorLabelName("ROC",0);
setDefaultBarFgColor(Color.red,0);
setPriceStudy(false);
var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
fp1.setName("DCH Length");
fp1.setDefault(4);
fp1.setLowerLimit(1);
var fp2 = new FunctionParameter("Lgth", FunctionParameter.NUMBER);
fp2.setName("Close Length");
fp2.setDefault(8);
fp2.setLowerLimit(1);
}
var vVClose = null;//vValueH1 = null, vValueL1 = null,
function main(Length, Lgth){
var vSm, vValueH1, vValueL1;
vVClose = getValue("Close", 0, -Lgth);
//if (vVClose == null) return;
if (getBarState() == BARSTATE_ALLBARS) {
myDCHstudy1 = new DonchianStudy(Length, 0);
}
vValueH1 = myDCHstudy1.getValue(DonchianStudy.UPPER);
vValueL1 = myDCHstudy1.getValue(DonchianStudy.LOWER);
if (vValueH1 == null|| vValueL1 == null ) return;
// vSm = 0;
//for(i = 0; i < Lgth+1; i++) {
// vSm += vC[i] - vC[i + 1];
// }
//vSm = vSm/(vValueH1-vValueL1);
return new Array ( vVClose );
}
Comment