I've been trying to use Bar (not tick) replay to debug EFS scripts (intraday, 15min charts).
But I find yet more complications:
1) With ComputeOnClose() set I don't get any "current" bars. That is, I see historic bars (last one is -1), but then when I click "Play" or "Step forward", I see the new bars on the charts, but main() is not called. Why??
2) With ComputeOnClose() not set I do get "current" bars. BUT the getBarState() changes from historic to current bars.
That is, I see historic bars (last one is 0) with state == NEWBAR, but then when I click "Play" or "Step forward", I see state == CURRENTBAR. Why??
All these inconsistencies are time-wasting obstacles to just getting on with writing code.
See code to test this follows
But I find yet more complications:
1) With ComputeOnClose() set I don't get any "current" bars. That is, I see historic bars (last one is -1), but then when I click "Play" or "Step forward", I see the new bars on the charts, but main() is not called. Why??
2) With ComputeOnClose() not set I do get "current" bars. BUT the getBarState() changes from historic to current bars.
That is, I see historic bars (last one is 0) with state == NEWBAR, but then when I click "Play" or "Step forward", I see state == CURRENTBAR. Why??
All these inconsistencies are time-wasting obstacles to just getting on with writing code.
See code to test this follows
PHP Code:
function preMain() {
//setComputeOnClose();
debugPrint("preMain"+ " isComputeOnClose() = "+ (isComputeOnClose() == true? "true":"false"));
}
// for n is 0 to 60 usually, ie time / date in hh mm ss etc
function TwoOrMoreDigits(n) {var s = n.toString(); if (s.length == 1) s = "0"+s; return s;}
// naf, for bar index
function ThreeOrMoreDigits(n) {var s = TwoOrMoreDigits(n); if (s.length == 2) s = "0"+s; return s;}
function WallClockString() {
var dDate = new Date(); // we only need this when we get to current bars ? Ideally use one from start of _main(){}
return TwoOrMoreDigits(dDate.getMonth())+"/"+TwoOrMoreDigits(dDate.getDate())+"-"
+TwoOrMoreDigits(dDate.getHours())+":"+TwoOrMoreDigits(dDate.getMinutes())+":"+TwoOrMoreDigits(dDate.getSeconds());
}
function sBarState(n) {
if (n == BARSTATE_NEWBAR) return "NEWBAR ";
if (n == BARSTATE_CURRENTBAR) return "TICK ";
if (n == BARSTATE_ALLBARS) return "ALLBARS";
return "?????";
}
function main() {
var iBar = getCurrentBarIndex();
var sIndex = iBar == 0? " 0":"-"+ThreeOrMoreDigits(-iBar);
debugPrint(" Bar: "+sIndex +" State: "+sBarState(getBarState())
+ ", isComputeOnClose() = "+ (isComputeOnClose() == true? "true":"false")
+ ", isReplayMode() = "+ (isReplayMode() == true? "true":"false")
+ ", WallClock() = " + WallClockString()
+"\n");
return null;
}
Comment