Hi Everyone
I have had trouble getting correct tick data, which synchronized with the Close of the interval.
For example we use a 1 minute interval chart of say AMZN and get Close of each interval by
var C = close();
Suppose we're also interested in 5 latest tick prices. Getting them by
var C_1Tick_a5 = getValue("close",0,-5,"AMZN,1T");
And we expect that C_1Tick_a5[0] is equal to C, but I found that is not the case with the following efs:
/****************************************/
var Sym, Interval, SymInterval, Sym1T;
function preMain() {
setStudyTitle("Data_test");
setCursorLabelName("C",0);
setCursorLabelName("C_1Tick",1);
setCursorLabelName("C_1Tick_a5[0]",2);
setCursorLabelName("C_1Tick_a5[1]",3);
setCursorLabelName("C_1Tick_a5[2]",4);
setCursorLabelName("C_1Tick_a5[3]",5);
setCursorLabelName("C_1Tick_a5[4]",6);
setCursorLabelName("10",10);
setDefaultBarFgColor(Color.teal,0);
setDefaultBarFgColor(Color.blue,1);
setDefaultBarFgColor(Color.green,2);
}
function main() {
var nBarState = getBarState();
if(nBarState == BARSTATE_ALLBARS) {
Sym = getSymbol();
Interval = getInterval();
SymInterval = Sym + "," + Interval;
Sym1T = Sym + "," + "1T";
}
var Real = 0; //Assuming historical data
// Check for real time calculation
if(isLastBarOnChart()) {
Real = 1;
var C = close();
var C_1Tick = getValue("close",Sym1T);
var C_1Tick_a5 = getValue("close",0,-5,Sym1T);
if(C_1Tick_a5 == null) {return new Array(Real,15);} // Null check
}
else {
return;
}
return new Array (C,C_1Tick,C_1Tick_a5[0],C_1Tick_a5[1],C_1Tick_a5[2],C_1Tick_a5[3],C_1Tick_a5[4]);
}
/***********************************************/
I ran tick replay of AMZN data of 08/15/03 using the above efs and found that C_1Tick_a5[0],C_1Tick_a5[1],C_1Tick_a5[2],C_1Tick_a5[3],C_1Tick_a5[4] were not the 5 latest tick prices for any moment of time, particularly at the close of each interval. For example, at 07:21 of 08/15/03 the data (from download file)are:
T,030815,072107,40.16,100,NMS
T,030815,072109,40.17,100,NMS
T,030815,072113,40.16,500,NMS
T,030815,072114,40.18,200,PSE
T,030815,072121,40.18,600,PSE
T,030815,072125,40.18,2000,NMS
T,030815,072128,40.14,500,CSE
T,030815,072129,40.14,100,CSE
T,030815,072142,40.17,100,PSE
T,030815,072143,40.18,200,PSE
T,030815,072143,40.18,100,PSE
T,030815,072143,40.18,100,PSE
T,030815,072144,40.19,300,PSE
T,030815,072145,40.19,100,NMS
T,030815,072145,40.19,100,CSE
T,030815,072148,40.19,700,PSE
T,030815,072148,40.19,100,PSE
T,030815,072148,40.19,100,PSE
T,030815,072149,40.19,100,CSE
T,030815,072150,40.19,1000,NMS
and the data of the first tick of the 07:22 interval are:
T,030815,072205,40.2,400,NMS
While, the efs gave:
C = 40.19 [correct Close]
but incorrect tick data
C_1Tick_a5[0] = 40.18 [incorrect, it's the 9th latest, not the latest tick !]
C_1Tick_a5[1] = 40.18 [incorrect, it's the 10th latest]
C_1Tick_a5[2] = 40.18 [incorrect, it's the 11th latest]
C_1Tick_a5[3] = 40.17 [incorrect, it's the 12th latest]
C_1Tick_a5[4] = 40.14 [incorrect, it's the 13th latest]
Please help. Thanks.
Regards
Dzung Nguyen
I have had trouble getting correct tick data, which synchronized with the Close of the interval.
For example we use a 1 minute interval chart of say AMZN and get Close of each interval by
var C = close();
Suppose we're also interested in 5 latest tick prices. Getting them by
var C_1Tick_a5 = getValue("close",0,-5,"AMZN,1T");
And we expect that C_1Tick_a5[0] is equal to C, but I found that is not the case with the following efs:
/****************************************/
var Sym, Interval, SymInterval, Sym1T;
function preMain() {
setStudyTitle("Data_test");
setCursorLabelName("C",0);
setCursorLabelName("C_1Tick",1);
setCursorLabelName("C_1Tick_a5[0]",2);
setCursorLabelName("C_1Tick_a5[1]",3);
setCursorLabelName("C_1Tick_a5[2]",4);
setCursorLabelName("C_1Tick_a5[3]",5);
setCursorLabelName("C_1Tick_a5[4]",6);
setCursorLabelName("10",10);
setDefaultBarFgColor(Color.teal,0);
setDefaultBarFgColor(Color.blue,1);
setDefaultBarFgColor(Color.green,2);
}
function main() {
var nBarState = getBarState();
if(nBarState == BARSTATE_ALLBARS) {
Sym = getSymbol();
Interval = getInterval();
SymInterval = Sym + "," + Interval;
Sym1T = Sym + "," + "1T";
}
var Real = 0; //Assuming historical data
// Check for real time calculation
if(isLastBarOnChart()) {
Real = 1;
var C = close();
var C_1Tick = getValue("close",Sym1T);
var C_1Tick_a5 = getValue("close",0,-5,Sym1T);
if(C_1Tick_a5 == null) {return new Array(Real,15);} // Null check
}
else {
return;
}
return new Array (C,C_1Tick,C_1Tick_a5[0],C_1Tick_a5[1],C_1Tick_a5[2],C_1Tick_a5[3],C_1Tick_a5[4]);
}
/***********************************************/
I ran tick replay of AMZN data of 08/15/03 using the above efs and found that C_1Tick_a5[0],C_1Tick_a5[1],C_1Tick_a5[2],C_1Tick_a5[3],C_1Tick_a5[4] were not the 5 latest tick prices for any moment of time, particularly at the close of each interval. For example, at 07:21 of 08/15/03 the data (from download file)are:
T,030815,072107,40.16,100,NMS
T,030815,072109,40.17,100,NMS
T,030815,072113,40.16,500,NMS
T,030815,072114,40.18,200,PSE
T,030815,072121,40.18,600,PSE
T,030815,072125,40.18,2000,NMS
T,030815,072128,40.14,500,CSE
T,030815,072129,40.14,100,CSE
T,030815,072142,40.17,100,PSE
T,030815,072143,40.18,200,PSE
T,030815,072143,40.18,100,PSE
T,030815,072143,40.18,100,PSE
T,030815,072144,40.19,300,PSE
T,030815,072145,40.19,100,NMS
T,030815,072145,40.19,100,CSE
T,030815,072148,40.19,700,PSE
T,030815,072148,40.19,100,PSE
T,030815,072148,40.19,100,PSE
T,030815,072149,40.19,100,CSE
T,030815,072150,40.19,1000,NMS
and the data of the first tick of the 07:22 interval are:
T,030815,072205,40.2,400,NMS
While, the efs gave:
C = 40.19 [correct Close]
but incorrect tick data
C_1Tick_a5[0] = 40.18 [incorrect, it's the 9th latest, not the latest tick !]
C_1Tick_a5[1] = 40.18 [incorrect, it's the 10th latest]
C_1Tick_a5[2] = 40.18 [incorrect, it's the 11th latest]
C_1Tick_a5[3] = 40.17 [incorrect, it's the 12th latest]
C_1Tick_a5[4] = 40.14 [incorrect, it's the 13th latest]
Please help. Thanks.
Regards
Dzung Nguyen
Comment