I use the following script to test the overhead of getValue().
The average time is 7ms when the main() is executed, which imply the overhead of getValue() is quite significant. Could someone tell me the reason and any tip to lower such overhead?
var ko;
function preMain() {
setPriceStudy(false);
/* Set the title that will appear in the study pane */
setStudyTitle("test");
setCursorLabelName("O");
/* Set the label that will appear in the cursor window */
addBand(100, PS_SOLID, 1, Color.blue);
addBand(0, PS_SOLID, 1, Color.red);
addBand(-100, PS_SOLID, 1, Color.blue);
}
function main(nInputLength, nConst) {
if(nInputLength == null)
nInputLength = 20;
if(nInputLength <= 0)
nInputLength = 20;
for ( var i = 0; i < 10; i ++ ) {
vHigh = getValue("High", -1, -(nInputLength+1));
vLow = getValue("Low", -1, -(nInputLength+1));
vClose = getValue("Close", -1, -(nInputLength+1));
}
return 50;
}
The average time is 7ms when the main() is executed, which imply the overhead of getValue() is quite significant. Could someone tell me the reason and any tip to lower such overhead?
var ko;
function preMain() {
setPriceStudy(false);
/* Set the title that will appear in the study pane */
setStudyTitle("test");
setCursorLabelName("O");
/* Set the label that will appear in the cursor window */
addBand(100, PS_SOLID, 1, Color.blue);
addBand(0, PS_SOLID, 1, Color.red);
addBand(-100, PS_SOLID, 1, Color.blue);
}
function main(nInputLength, nConst) {
if(nInputLength == null)
nInputLength = 20;
if(nInputLength <= 0)
nInputLength = 20;
for ( var i = 0; i < 10; i ++ ) {
vHigh = getValue("High", -1, -(nInputLength+1));
vLow = getValue("Low", -1, -(nInputLength+1));
vClose = getValue("Close", -1, -(nInputLength+1));
}
return 50;
}
Comment