Is there a short, easy way that I can replace a function call like close() with a variable name like vOHLC() (as in example 1) or am I just going to have to use a longer test for the parameter setting (as in example 2)?
Dale Sullivan
Dale Sullivan
PHP Code:
// *** EXAMPLE 1 ***
var fp1 = new FunctionParameter("vOHLC", FunctionParameter.STRING);
fp1.setName("vOHLC");
fp1.addOption("open");
fp1.addOption("high");
fp1.addOption("low");
fp1.addOption("close");
fp1.setDefault("close");
}
function main(vOHLC) {
vPrice1 = close(vSymbol);
vPrice2 = vOHLC(vSymbol) + 4;
return new Array(vPrice1, vPrice2);
}
PHP Code:
// *** EXAMPLE 2 ***
var fp1 = new FunctionParameter("vOHLC", FunctionParameter.STRING);
fp1.setName("vOHLC");
fp1.addOption("open");
fp1.addOption("high");
fp1.addOption("low");
fp1.addOption("close");
fp1.setDefault("close");
}
function main(vOHLC) {
vPrice1 = close(vSymbol);
switch (vOHLC) {
case "open" :
vPrice2 = open(vSymbol) + 4;
break;
case "high" :
vPrice2 = high(vSymbol) + 4;
break;
case "low" :
vPrice2 = low(vSymbol) + 4;
break;
case "close" :
vPrice2 = close(vSymbol) + 4;
break;
default :
vPrice2 = close(vSymbol) + 4;
}
return new Array(vPrice1, vPrice2);
Comment