I am having trouble with the code below. I am trying to just pass a symbol to a funtion udTick and have it return a 1, -1 or 0 which is whether the symbol is on uptick, downtick or unchanged. It works fine as it is below, but if i uncomment out the line for nq #f, the number returned is always the same, but if i check it in the function itself, it works properly. For some reseaon when i run the function more than once, the return numbers dont change. Any ideas? Another question, using the dde command winros in excel, what is the variable to see whether a stock is on up or down tick?
var ntick_1 = null;
var ntick = null;
function udTick(symbol) {
var tc = 0;
if (getCurrentBarIndex() < 0) return;
ntick_1 = ntick;
ntick = close(0,symbol);
if (ntick > ntick_1) {
//uptick
tc = 1;
} else if (ntick < ntick_1) {
//downtick
tc = -1;
}
// debugPrint(tc);
return tc;
}
function main(){
var counter = 0;
var counter1 = 1;
var counter2 = 2;
var counter3 = 0;
//counter = udTick("nq #f");
counter1 = udTick("es #f");
counter3 = counter + counter1 + counter2;
debugPrintln("counter---->"+ counter);
debugPrintln(" count #1---> " + counter1 );
debugPrintln( " count #2---> " + counter2);
debugPrintln( " count #3---->" + counter3);
var ntick_1 = null;
var ntick = null;
function udTick(symbol) {
var tc = 0;
if (getCurrentBarIndex() < 0) return;
ntick_1 = ntick;
ntick = close(0,symbol);
if (ntick > ntick_1) {
//uptick
tc = 1;
} else if (ntick < ntick_1) {
//downtick
tc = -1;
}
// debugPrint(tc);
return tc;
}
function main(){
var counter = 0;
var counter1 = 1;
var counter2 = 2;
var counter3 = 0;
//counter = udTick("nq #f");
counter1 = udTick("es #f");
counter3 = counter + counter1 + counter2;
debugPrintln("counter---->"+ counter);
debugPrintln(" count #1---> " + counter1 );
debugPrintln( " count #2---> " + counter2);
debugPrintln( " count #3---->" + counter3);
Comment