Hi. Please help, I am very confused. This snippet shows problem occurring in longer script. Basically I can't seem to get sym() to work inside open() and produce a series. Oddly if I follow the failing line with a line that should be wrong (it has a ticker, but no sym() round it), the failing line starts to work. That is just bizarre. I know I'm new, but how can I get this so wrong?
Next day - a PS: On another machine I get variable results, the first time I ran this I got the "nul" debugprint. I added the "should be faulty" line (the one without the sym()) and both lines worked. I removed the faulty line and the original line now prints the numeric value. What is going on?
Next day - a PS: On another machine I get variable results, the first time I ran this I got the "nul" debugprint. I added the "should be faulty" line (the one without the sym()) and both lines worked. I removed the faulty line and the original line now prints the numeric value. What is going on?
PHP Code:
var bStudyInit = false;
function preMain() {
setStudyTitle("Barmy1");
setCursorLabelName("Barmy1");
}
function main() {
if ( bStudyInit == false ) { // (aside - Why not use "getBarState() == BARSTATE_ALLBARS" for one-time inits?
// if the SECOND debugPrint line is commented out the FIRST line does not print correctly,
// but according to the help pages (KB), the second line is not correct anyway, as sym() is required if the the symbol is specified.
debugPrint("Script is loading1a, open(-1): " + open(-1,sym("IBM,5")) + "\n");
// debugPrint("Script is loading1b, open(-1): " + open(-1,"AAPL,5") + "\n");
// With BOTH lines I get (in order shown in debug window):
// Script is loading1b, open(-1): 109.64
// Script is loading1a, open(-1): 105.81
// With the SECOND line commented out I get:
// Script is loading1b, open(-1): null
// Why is this null?????? (in the PREVIOUS line to the commented one). Not a good start for my first script.
debugPrint("Script is loading 2\n");
// this is what I expected to do (within an object), it doesn't work either
// var serSym = sym("IBM" + "," + nInterval.toString()); // this is the series ofbect for this interva;
// debugPrint("Script is loading3, open(-1): " + open(-1,serSym) + "\n");
bStudyInit = true;
}
return 0;
}
Comment