Hi
A function (test()) is called using efsInternal and passed a series that is different to the chart (say ES,200V for the passed series vs ES,1 for the chart). The Test() routine returns an array of three (series of) numbers, the first is the barcount (as a negative), the second an internal counter (also negative) and the third is the getBarState() value (0 = BARSTATE_NEWBAR, 1 BARSTATE_CURRENTBAR).
While historic bars are processed I don't get a problem, but when the current bar ticks arrive there seems to be missing data (except for the very first one).
The output generally shows a line printed in the Test() code, followed by a line in the Caller() (ie main()), this is what I expect (as we have got to the current bar).
For starters note that the Test() routine is often apparently frequently called twice between Caller() lines (see unchanged volume print suggesting simple duplication). For ticks in the current bar I would expect the efsInternal()ed Test() code to be called once per tick, like main() is? This would appear to indicate an erroneous call to Test()?
But more awkward is what happens when the 200V series gets a NEWBAR. See that it is detected in the Test() code (see "c = 0" value and the "...!!! NEWBAR DETECTED!!!.." print).
But in the Caller() code we simply don't get to process the NEWBAR for the 200V series - see there is no Caller line with c = 0. As my Test() routine is actually meant to do processing and return meaningful data only when a NEWBAR does occur this is a problem.
Here is the code, I can't see anything stupid, so I think it is a bug?
10.1.1291.910 (7/14/2008)
-------------------------- ENDED HISTORIC BARS -------------------------------------
Caller(): a = -305 b = -305 c = 0
Caller(): ----------------------------- NEWBAR Returned -----------------------------------------------
Test(): a = -305 b = -306 c = 1 Vol = 98
Caller(): a = -305 b = -306 c = 1
Test(): a = -305 b = -307 c = 1 Vol = 100
Test(): a = -305 b = -308 c = 1 Vol = 100
Caller(): a = -305 b = -308 c = 1
Test(): a = -305 b = -309 c = 1 Vol = 100
Caller(): a = -305 b = -309 c = 1
Test(): a = -305 b = -310 c = 1 Vol = 198
Test(): a = -305 b = -311 c = 1 Vol = 198
Caller(): a = -305 b = -311 c = 1
Test(): a = -305 b = -312 c = 1 Vol = 198
Caller(): a = -305 b = -312 c = 1
Test(): a = -305 b = -313 c = 1 Vol = 199
Test(): a = -305 b = -314 c = 1 Vol = 199
Caller(): a = -305 b = -314 c = 1
Test(): a = -305 b = -315 c = 1 Vol = 199
Caller(): a = -305 b = -315 c = 1
Test(): a = -305 b = -316 c = 1 Vol = 200
Test(): a = -305 b = -317 c = 1 Vol = 200
Caller(): a = -305 b = -317 c = 1
Test(): !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NEWBAR DETECTED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Test(): a = -306 b = -318 c = 0 Vol = 50
Test(): a = -306 b = -319 c = 1 Vol = 50
Caller(): a = -306 b = -319 c = 1
Test(): a = -306 b = -320 c = 1 Vol = 50
Caller(): a = -305 b = -305 c = 0
Caller(): ----------------------------- NEWBAR Returned -----------------------------------------------
Test(): a = -305 b = -306 c = 1 Vol = 98
Caller(): a = -305 b = -306 c = 1
Test(): a = -305 b = -307 c = 1 Vol = 100
Test(): a = -305 b = -308 c = 1 Vol = 100
Caller(): a = -305 b = -308 c = 1
Test(): a = -305 b = -309 c = 1 Vol = 100
Caller(): a = -305 b = -309 c = 1
Test(): a = -305 b = -310 c = 1 Vol = 198
Test(): a = -305 b = -311 c = 1 Vol = 198
Caller(): a = -305 b = -311 c = 1
Test(): a = -305 b = -312 c = 1 Vol = 198
Caller(): a = -305 b = -312 c = 1
Test(): a = -305 b = -313 c = 1 Vol = 199
Test(): a = -305 b = -314 c = 1 Vol = 199
Caller(): a = -305 b = -314 c = 1
Test(): a = -305 b = -315 c = 1 Vol = 199
Caller(): a = -305 b = -315 c = 1
Test(): a = -305 b = -316 c = 1 Vol = 200
Test(): a = -305 b = -317 c = 1 Vol = 200
Caller(): a = -305 b = -317 c = 1
Test(): !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NEWBAR DETECTED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Test(): a = -306 b = -318 c = 0 Vol = 50
Test(): a = -306 b = -319 c = 1 Vol = 50
Caller(): a = -306 b = -319 c = 1
Test(): a = -306 b = -320 c = 1 Vol = 50
While historic bars are processed I don't get a problem, but when the current bar ticks arrive there seems to be missing data (except for the very first one).
The output generally shows a line printed in the Test() code, followed by a line in the Caller() (ie main()), this is what I expect (as we have got to the current bar).
For starters note that the Test() routine is often apparently frequently called twice between Caller() lines (see unchanged volume print suggesting simple duplication). For ticks in the current bar I would expect the efsInternal()ed Test() code to be called once per tick, like main() is? This would appear to indicate an erroneous call to Test()?
But more awkward is what happens when the 200V series gets a NEWBAR. See that it is detected in the Test() code (see "c = 0" value and the "...!!! NEWBAR DETECTED!!!.." print).
But in the Caller() code we simply don't get to process the NEWBAR for the 200V series - see there is no Caller line with c = 0. As my Test() routine is actually meant to do processing and return meaningful data only when a NEWBAR does occur this is a problem.
Here is the code, I can't see anything stupid, so I think it is a bug?
10.1.1291.910 (7/14/2008)
PHP Code:
function preMain() {
setStudyTitle("efsInternal DEBUG missing return for NEWBAR in different series");
}
var mbOnceInit = false;
var mSeries2 = null;
var msInt = "200V"; // run on a chart that is not 200V
var ms = null;
var mbLast = false;
function main (){
if (!mbOnceInit) {
mSeries2 = sym(getSymbol()+"," + msInt);
ms = efsInternal("Test", mSeries2);
mbOnceInit = true;
}
if (!mbLast && isLastBarOnChart()) {
mbLast = true;
debugPrint("\n -------------------------- ENDED HISTORIC BARS -------------------------------------\n\n");
}
debugPrint("Caller(): a = " + getSeries(ms,0).getValue(0) + " b = " + getSeries(ms,1).getValue(0) + " c = " + getSeries(ms,2).getValue(0) + "\n");
if (getSeries(ms,2).getValue(0) == BARSTATE_NEWBAR) {
debugPrint("Caller(): ----------------------------- NEWBAR Returned -----------------------------------------------" + "\n");
}
return getSeries(ms,0).getValue(0),getSeries(ms,2).getValue(0);
}
var mnNoTest = 0;
var mnDummy = 0;
function Test( serSource) { // executes in serSource (ie getBarState(), volume()
var nBS = getBarState();
if ( nBS == BARSTATE_NEWBAR ) {
// note that for historical bars these don't occur synchronoulsy with the caller (the series is built eparately)
debugPrint("Test(): !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NEWBAR DETECTED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + "\n");
}
mnDummy --;
var a = -getCurrentBarCount() ;
var b = mnDummy ;
var c = nBS; // should see splinkling of BARSTATE_NEWBAR in many BARSTATE_CURRENTBAR
debugPrint("Test(): " + "a = " + a + " b = " + b + " c = " + c + " Vol = " + volume() + "\n");
return new Array(a,b,c);
}
Comment