I encountered a very strange error while debuging my EFS. I wrote the attached simplified EFS to reproduce the error. If you apply this EFS to an advanced chart showing ($TICK,T) with time template 8:30-16:00. In some cases, when tick is larger than tick1, the result of "tick > (tick1 + 0.5)" is false. For example, in the output window, near the line "t = 3363 ......", tick = -31, tick1 = -49, but the program considers the tick is smaller than tick1. Similar cases appear at other lines. It seems this error most likely occurs when tick accrosses 0 and it appears quite randomly. Help is greatly appreciated.
/* Reproduce the Bug */
var tick, tick1, t;
function preMain() {
setStudyMin(0);
setStudyMax(280);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setStudyTitle("Test");
t = 0;
}
function main() {
if ( getBarState() == BARSTATE_NEWBAR ) {
var ticktmp = tick;
tick1 = ticktmp;
tick = getValue("Close", 0, 1, "$TICK,T");
//t = getValue("Time", 0, 1, "$TICK.T");
t = t + 1;
var W;
W = Math.round(tick);
if ( tick > (tick1 + 0.5) ) {
debugPrintln("t = " + t + " Tick = " + tick + " Tick1 = " + tick1 + " up");
}
else {
debugPrintln("t = " + t + " Tick = " + tick + " Tick1 = " + tick1 + " down");
}
}
}
/* Reproduce the Bug */
var tick, tick1, t;
function preMain() {
setStudyMin(0);
setStudyMax(280);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setStudyTitle("Test");
t = 0;
}
function main() {
if ( getBarState() == BARSTATE_NEWBAR ) {
var ticktmp = tick;
tick1 = ticktmp;
tick = getValue("Close", 0, 1, "$TICK,T");
//t = getValue("Time", 0, 1, "$TICK.T");
t = t + 1;
var W;
W = Math.round(tick);
if ( tick > (tick1 + 0.5) ) {
debugPrintln("t = " + t + " Tick = " + tick + " Tick1 = " + tick1 + " up");
}
else {
debugPrintln("t = " + t + " Tick = " + tick + " Tick1 = " + tick1 + " down");
}
}
}
Comment