Hi, I am getting a syntax error on line 40:
"Reference error:vMA is not defined"
Can anybody help me? Thanks
function preMain() {
setPriceStudy(false);
setStudyTitle("NickMBigMove");
setCursorLabelName("Signal", 0);
setDefaultBarFgColor(Color.red, 0);
setPlotType(PLOTTYPE_HISTOGRAM,0);
setHistogramBase(0);
setDefaultBarThickness(1,0);
var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(20); //Edit this value to set a new default
var fp2 = new FunctionParameter("Offset", FunctionParameter.NUMBER);
fp2.setDefault(0); //Edit this value to set a new default
var fp3 = new FunctionParameter("Source", FunctionParameter.STRING);
fp3.setName("Source");
fp3.addOption("Close");
fp3.addOption("High");
fp3.addOption("Low");
fp3.addOption("Open");
fp3.addOption("HL/2");
fp3.addOption("HLC/3");
fp3.addOption("OHLC/4");
fp3.setDefault("Close"); //Edit this value to set a new default
var fp4 = new FunctionParameter("ATRMultiple", FunctionParameter.NUMBER);
fp4.setName("Constant");
fp4.setLowerLimit(0.0001);
fp4.setDefault(1.5); //Edit this value to set a new default
var fp5 = new FunctionParameter("StdDev", FunctionParameter.NUMBER);
fp5.setLowerLimit(0);
fp5.setDefault(2); //Edit this value to set a new default
}
function main(Length,Offset,Source,ATRMultiple,StdDev) {
if (vMA == null) vMA = new MAStudy(Length, Offset, Source, MAStudy.SIMPLE);
if (vMA1 == null) vMA1 = new MAStudy(Length, Offset, "High", MAStudy.SIMPLE);
if (vMA2 == null) vMA2 = new MAStudy(Length, Offset, "Low", MAStudy.SIMPLE);
if (vBB == null) vBB = new BollingerStudy(Length, Source, StdDev);
if(vMA.getValue(MAStudy.MA)==null)
return;
var xATR = (vMA1.getValue(MAStudy.MA)-vMA2.getValue(MAStudy.MA));
vUpper = vMA.getValue(MAStudy.MA)+(xATR*ATRMultiple);
vLower = vMA.getValue(MAStudy.MA)-(xATR*ATRMultiple);
var vBBUpper = vBB.getValue(BollingerStudy.UPPER);
var vBBLower = vBB.getValue(BollingerStudy.LOWER);
if(vBBUpper <= vUpper && vBBLower >= vLower){
var vPlot = 1;
}
return vPlot;
}
"Reference error:vMA is not defined"
Can anybody help me? Thanks
function preMain() {
setPriceStudy(false);
setStudyTitle("NickMBigMove");
setCursorLabelName("Signal", 0);
setDefaultBarFgColor(Color.red, 0);
setPlotType(PLOTTYPE_HISTOGRAM,0);
setHistogramBase(0);
setDefaultBarThickness(1,0);
var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(20); //Edit this value to set a new default
var fp2 = new FunctionParameter("Offset", FunctionParameter.NUMBER);
fp2.setDefault(0); //Edit this value to set a new default
var fp3 = new FunctionParameter("Source", FunctionParameter.STRING);
fp3.setName("Source");
fp3.addOption("Close");
fp3.addOption("High");
fp3.addOption("Low");
fp3.addOption("Open");
fp3.addOption("HL/2");
fp3.addOption("HLC/3");
fp3.addOption("OHLC/4");
fp3.setDefault("Close"); //Edit this value to set a new default
var fp4 = new FunctionParameter("ATRMultiple", FunctionParameter.NUMBER);
fp4.setName("Constant");
fp4.setLowerLimit(0.0001);
fp4.setDefault(1.5); //Edit this value to set a new default
var fp5 = new FunctionParameter("StdDev", FunctionParameter.NUMBER);
fp5.setLowerLimit(0);
fp5.setDefault(2); //Edit this value to set a new default
}
function main(Length,Offset,Source,ATRMultiple,StdDev) {
if (vMA == null) vMA = new MAStudy(Length, Offset, Source, MAStudy.SIMPLE);
if (vMA1 == null) vMA1 = new MAStudy(Length, Offset, "High", MAStudy.SIMPLE);
if (vMA2 == null) vMA2 = new MAStudy(Length, Offset, "Low", MAStudy.SIMPLE);
if (vBB == null) vBB = new BollingerStudy(Length, Source, StdDev);
if(vMA.getValue(MAStudy.MA)==null)
return;
var xATR = (vMA1.getValue(MAStudy.MA)-vMA2.getValue(MAStudy.MA));
vUpper = vMA.getValue(MAStudy.MA)+(xATR*ATRMultiple);
vLower = vMA.getValue(MAStudy.MA)-(xATR*ATRMultiple);
var vBBUpper = vBB.getValue(BollingerStudy.UPPER);
var vBBLower = vBB.getValue(BollingerStudy.LOWER);
if(vBBUpper <= vUpper && vBBLower >= vLower){
var vPlot = 1;
}
return vPlot;
}
Comment